rajithd / spring-boot-oauth2

Spring Boot Oauth2 with H2 database
208 stars 166 forks source link

How to get authorization code ? Then access token ? #22

Open domiq44 opened 1 year ago

domiq44 commented 1 year ago

Hello,

Very interesting job. Thank you for it.

I would like, in order, retrieve (See What is the OAuth 2.0 Authorization Code Grant Type?) :

  1. authorization code using :
    1. url http://localhost:9191/api/oauth/authorize,
    2. client_id.
  2. access token using :
    1. url http://localhost:9191/api/oauth/token,
    2. authorization code retrieved before.

So I've tried this command line (using curl) :

curl -i http://localhost:9191/api/oauth/authorize?client_id=rajithapp&response_type=code&redirect_uri=http://127.0.0.1:12345&scope=openid+read+write

but I am redirected to http://localhost:9191/api/login with no login window !?

HTTP/1.1 302 Found
Server: Apache-Coyote/1.1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
Set-Cookie: JSESSIONID=0FE591086EDD5FD13DA2AAB0AB344CAC; Path=/api/; HttpOnly
Location: http://localhost:9191/api/login
Content-Length: 0
Date: Fri, 31 Mar 2023 15:49:38 GMT

How can I get authorization code ? Then, I will be able to retrieve access token.

Can you help me please ?