myndocs / kotlin-oauth2-server

Flexible OAuth2 server library. Support for multiple frameworks
Apache License 2.0
151 stars 25 forks source link

How to use? #41

Closed Savrov closed 2 years ago

Savrov commented 5 years ago

I'm totally new, can you provide some info how to use it in my REST endpoints? I'm using this lib for Ktor

I've installed the feature but how I can access Oauth2TokenService class with /auth endpoint?

adhesivee commented 5 years ago

I have to update documentation about this. The default links can be found here https://github.com/myndocs/kotlin-oauth2-server/blob/develop/oauth2-server-core/src/main/java/nl/myndocs/oauth2/config/CallRouterBuilder.kt#L9-L11

sergiocasero commented 5 years ago

Hello! I'm also a little bit confused. I've configured everything on the app but I don't know how to use it.

When I try to get the token with postman (for example) I just get an empty page, could you please add a "full" sample about how to use it for noobs?

adhesivee commented 5 years ago

@sergiocasero I think there is quite some information available how to use oauth Maybe I can include some basic example but I dont know in which format yet

If you POST to token endpoint I think it should always respond with something. This might be a bug, did you see an exceptions showing up in the log?

sergiocasero commented 5 years ago

Hello, the logs don't say anything (using ktor)

this is my configuration:

install(Oauth2ServerFeature) {
        identityService = InMemoryIdentity()
            .identity {
                username = "test"
                password = "test"
            }

        clientService = InMemoryClient()
            .client {
                clientId = "test"
                clientSecret = "test"
                scopes = setOf("test")
                redirectUris = setOf("http://localhost:8080/callback")
                authorizedGrantTypes = setOf(AuthorizedGrantType.AUTHORIZATION_CODE)
            }

        tokenStore = InMemoryTokenStore()
    }

And this is the postman config: imagen

And postman says... imagen

Also, I don't how to encapsulate my requests into the "auth" section. When I use the ktor auth module, I always put the routings inside authentication { } block, but it seems to be not working with the lib-

adhesivee commented 5 years ago

@sergiocasero I tested it with postman. Postman seems to be the problem here. That empty page what you see is the part where you normally login with basic authentication (/oauth/authorize). It seems you can not use basic auth for authorization endpoints in postman. With the coming release form logins could be supported. I need to create examples for this too. I will create an issue (#67).

I am not sure what you mean with: I always put the routings inside authentication { } block, but it seems to be not working with the lib Could you please open a new issue and give some examples what you mean?

sergiocasero commented 5 years ago

Yes... you was totally right, my bad sorry, the problem is POSTMAN, by making the requests manually looks like it works fine. Thanks for the awesome job! I'll open a new issue with the explanation of "encapsulating requests"