go-oauth2 / oauth2

OAuth 2.0 server library for the Go programming language.
https://pkg.go.dev/github.com/go-oauth2/oauth2/v4
MIT License
3.34k stars 568 forks source link

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

Open adriendomoison opened 5 years ago

adriendomoison commented 5 years ago

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!

LyricTian commented 5 years ago

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

adriendomoison commented 5 years ago

@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 👍

bendo01 commented 5 years ago

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

MkrierPharmanity commented 1 year ago

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