Conversation
…v1.1/students/{id})
| if user_type && user_id | ||
| @raw_user_info = access_token.get("/v1.1/#{user_type}s/#{user_id}").parsed | ||
| end | ||
| end |
There was a problem hiding this comment.
I have exactly the same use case, I needed more info than what the /me endpoint provided. But instead of building a URL from parts, I used the links collection that comes in the JSON returned from the /me endpoint. (An example of the links collection is at https://dev.clever.com/instant-login/users)
What do you think of something like this? This approach lets the API tell us where the canonical endpoint is for the user versus building up a URL from parts.
extra do
{
raw_info: me_attrs,
canonical: canonical_attrs
}
end
def me_attrs
@me_attrs ||= access_token.get('/me').parsed
end
def canonical_attrs
@canonical_attrs ||= access_token.get(canonical_endpoint).parsed
end
def canonical_endpoint
me_link('canonical').fetch('uri', '/me')
end
def me_link(rel)
me_attrs.fetch('links', []).detect { |link| link['rel'] == rel } || {}
end|
Thanks @jbusser for the update! We very much recommend using links!! |
|
Could we talk about either merging this PR or closing it? I am relying on a forked version of this gem to deliver this feature, and it would be nice to be back on a maintainer-supported gem. |
Gets additional data from /v1.1/teachers/{id} or /v1.1/students/{id} if option
get_user_infois set totrue.Example with devise: