-
Notifications
You must be signed in to change notification settings - Fork 694
Support custom grant types #344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Expose `fetchTokenUsingGrant` which can be used to send custom grant requests to the token endpoint. The password flow then becomes just a wrapper around that, where username and password are passed to the request. - Add `id_token` to `TokenResponse` type since this is part of the OIDC spec. Add handling for the ID token, so that it gets processed and stored properly. - Simplify `http.post` call by using `toPromise()` to convert Rx observable into a promise.
Rebased this against the current master. |
So there is still no support for custom grant types? |
I looked into this earlier today considering that the master has changed quite a lot in the past few days. I can easily rebase this on top of master, or even generalize this a bit further if desired. If there's interest, I will gladly move this change in the best direction. |
Well, I have to idea yet. Just looking into this library and evaluating it. Can you recommend any other library? |
I have made some simple changes to make things easy to extend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the status of this proposed change for the moment? Why is it not approved? We need custom grant type support in our Angular front-end (to implement passwordless login). Do we need to use a workaround without OAuthService?
Any news about this ? I really need this implementation. |
I gave up to wait for official change and just adopted the existing old pull request to my needs and latest version: https://github.com/manfredsteyer/angular-oauth2-oidc/pull/919 |
For those still following this issue: Support for custom grant types was just merged via #919. |
I had the problem that I am using a custom grant type to sign in the user and retrieve id and access token. Right now, grant types other
password
are not supported, so this is an attempt to add support for custom grant types.The
fetchTokenUsingGrant
function can be used to send a custom grant request to the token endpoint. The logic follows exactly what thefetchTokenUsingPasswordFlow
does. I actually moved all the logic out of that function, so the password flow is now just a specialization of the custom grant call.I also added support for the
id_token
in the token response. As per spec, the token endpoint can return theid_token
as well. For the implementation, I followed the logic oftryLogin
, except that I’m skipping the additional stuff from theLoginOptions
(users can always do that manually).To review the change, best look at the diff with
w=1
in the URL to ignore whitespace changes. To simplify thehttp.post
call, I usedtoPromise()
to convert the observable into a promise. That avoids having to wrap everything within a Promise constructor (which isn’t the most readable pattern anyway). Unfortunately, that change resulted in a changed indentation, so the diff isn’t that pretty.