Doorkeeper Refresh Token & Polymorphic association - oauth

Is it the expected behaviour not to populate the column resource_owner_type on token refresh grant?
The original token gets correctly associated to the resource owner (both id & type columns), but on refresh only the id gets saved

Related

What datatype should i use for saving the unique user id returned by an Oauth provider

I want to store the unique user id returned in the response by an Oauth provider in my SQL database. I've seen some posts suggesting that varchar(128) should be enough. Are there any providers whose user id extends this limit? I have checked the docs for some of the more popular providers like Google, Facebook and Github but I can't seem to find any information about the size of this user id.
OIDC defines the sub claim as:
A locally unique and never reassigned identifier within the Issuer for the End-User, which is intended to be consumed by the Client, e.g., 24400320 or AItOawmwtWwcT0k51BayewNvutrJUqsvl6qs7A4. It MUST NOT exceed 255 ASCII characters in length. The sub value is a case sensitive string.
So better use VARCHAR(255).

Unable to get the final calculated grade value for a student in a course

I have used the following api call
/d2l/api/le/1.2/courseid/grades/final/calculated/studentid
but I get an error message saying Error: Unknown: NOT_FOUND.
Does that mean the grade isn't posted or is it a security issue?
That API gets used to initiate a final grade re-calculation for a student. Your 404 Not Found error most likely means one of these things:
You are using the wrong HTTP Method for this route (i.e. you're making a PUT or GET call, when it should be a POST with an empty body)
Your LMS doesn't support the API version you're using (1.2 in your example)
You haven't specified the correct LMS Org Unit ID value for the course offering
You haven't specified the correct LMS User ID value for the student
Note that "correct value" for those last two must mean that the two entities exist and have an appropriate relationship (i.e. they both validly identity a course, and a user, respectively, and that the user is explicitly enrolled in the course offering with a gradeable role).

Creating new user with Valence API and setting profile data

I'm successfully creating a new user using the valence API, setting the password and enrolling the new user into appropriate OUs.
(I've used the API reference at: http://docs.valence.desire2learn.com/reference.html)
I'm logged on using an account created for the application accessing the REST API.
I also want to set some of the profile fields for the new user;
I think I need to use the put profile function:
PUT /d2l/api/lp/(D2LVERSION: version)/profile/(D2LID: profileId)
My issue is how to find the profile id for the user i've just created.
It isn't returned in the user data for the created user and I can't see the API call which would let me retrieve the profile id of the newly created user.
Can anyone point me in the right direction?
Cheers
Alan
After creating a user you will have its user ID. If you make the following call (documentation)
GET /d2l/api/lp/(D2LVERSION: version)/enrollments/orgUnits/(D2LID: orgUnitId)/users/
You will get a list of all users enrolled in the provided org unit. Note that the result set of this call is paged (see the docs.) Each entry in the result is a Enrollment.OrgUnitUser, which contains a property "user" with a User.User value - which contains the users profile identifier.
You can skip ahead to the user you want by setting the bookmark value to the users userID. See the note in the green box in the documentation for the call for more information.
You can always use the root org for the orgUnitID parameter.

Assigning object IDs with rails

Suppose I have a client side app that sends out requests to a rails back end. One of those requests would to create a new object, say a Post. In this case the client side app sends in a json request containing a post title and the post content.
But now suppose that the object needs to have an id as well, which the client side app doesn't provide. Is there a way for rails to automatically increment the previously created post's id and set the newly created objects id to this value?
Would I put this into the create method of PostsController? Or does this sort of logic belong in the model file?
Typically this is done at the database level. The tables rails generated for you will by default have an auto incrementing id column

Use authlogic to find the User record based on an associated record

Typically, with Authlogic, you would authenticate with some unique identifier (e.g. email or username) and a password. Authlogic does this by first finding the record by the identifier (User.find_by_email_address(email) or similar), then calling then .authenticate method on the returned object, which checks the password against the record.
What I want to do is change the way Authlogic finds the record (at a finer level than just changing the field it uses). My use case requires that the email_address column (in this case) is in an associated child model.
Essentially, I want to ask Authlogic to find my User record based on the presence of an associated Subscriber model that is uniquely identified by the email_address that is provided.
Has anyone seen Authlogic accommodate this?
You might probably want to configure a different #login_field.

Resources