oauth2 icon indicating copy to clipboard operation
oauth2 copied to clipboard

Do you have a working example of all the authentication method?

Open adriendomoison opened this issue 5 years ago • 4 comments

I am trying to implement all the OAuth2 authentication methods under the same program, but I am having an issue by just adding the Client Credential method to the example/server.go. When adding these two lines from your example in the readme to the example/server.go, the Authorization Code flow doesn't work anymore.

	srv.SetAllowGetAccessRequest(true)
	srv.SetClientInfoHandler(server.ClientFormHandler)

And if I remove the 2 lines Authorization Code is working again but Client Credentials fails of course.

       srv.SetUserAuthorizationHandler(userAuthorizeHandler)
       //srv.SetAllowGetAccessRequest(true)
       //srv.SetClientInfoHandler(server.ClientFormHandler)

So, either the Client Credential flow works, either the Authorization Code flow.

Can you advise on what is going on?

I think it would be great if you had a working server example with all the authentication method working together, this would make this open source oauth2 package far ahead from the other ones.

Thank you!

adriendomoison avatar Feb 11 '19 06:02 adriendomoison

I added an example of the use of password mode and client mode, you can check it out:https://github.com/go-oauth2/oauth2/tree/master/example

LyricTian avatar Feb 12 '19 01:02 LyricTian

@LyricTian Wow, that's awesome! This really changes the game thanks! I understand now at a glance how this implemetation of OAuth is built. I am impressed about how clean this is and how minimum work is required to implement a server 👍

adriendomoison avatar Feb 12 '19 06:02 adriendomoison

Do you have a working example using gorm ? i tried to combine example using buntDB and example in mysql but i've always get message Response Error: unsupported_grant_type

bendo01 avatar Feb 19 '19 13:02 bendo01

I added an example of the use of password mode and client mode, you can check it out:https://github.com/go-oauth2/oauth2/tree/master/example

def not working with code flow

MkrierPharmanity avatar Jan 17 '23 10:01 MkrierPharmanity