Skip to content

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

Closed
wants to merge 1 commit into from
Closed

Support custom grant types #344

wants to merge 1 commit into from

Conversation

poke
Copy link

@poke poke commented Jun 4, 2018

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 the fetchTokenUsingPasswordFlow 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 the id_token as well. For the implementation, I followed the logic of tryLogin, except that I’m skipping the additional stuff from the LoginOptions (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 the http.post call, I used toPromise() 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.

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.
@poke
Copy link
Author

poke commented Oct 18, 2018

Rebased this against the current master.

@heyarny
Copy link

heyarny commented Jul 19, 2019

So there is still no support for custom grant types?

@poke
Copy link
Author

poke commented Jul 19, 2019

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.

@heyarny
Copy link

heyarny commented Jul 19, 2019

Well, I have to idea yet. Just looking into this library and evaluating it.
I need custom grant types support and found this open issue.
So I guess it's not supported yet..

Can you recommend any other library?

@heyarny
Copy link

heyarny commented Jul 23, 2019

I have made some simple changes to make things easy to extend

#585

Copy link
Contributor

@alexandis alexandis left a 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?

@cda963
Copy link

cda963 commented Oct 12, 2020

Any news about this ? I really need this implementation.

@alexandis
Copy link
Contributor

alexandis commented Oct 12, 2020

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

@poke poke mentioned this pull request Jul 16, 2021
@poke
Copy link
Author

poke commented Jul 16, 2021

For those still following this issue: Support for custom grant types was just merged via #919.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants