Search code examples
springspring-bootspring-securityoauth-2.0spring-oauth2

Spring OAuth2 - how to use the /oauth/authenticate endpoint?


So...I'm struggling to implement an authorization server with using Spring Boot OAuth2. For now I get a 403 response on:

GET oauth/authorize?username=demo&password=demo&client_id=demo&response_type=token

For the love of god, is the request okay? I would like to call this endpoint from a browser application and it should return an access_token and a refresh_token. Why do I need to provide a client_id for this? I'm on the edge of a mental breakdown because of this. How are you supposed to send a request to this endpoint?

The response is:

{
  "timestamp": "2019-09-15T05:03:17.206+0000",
  "status": 403,
  "error": "Forbidden",
  "message": "Access Denied",
  "path": "/oauth/authorize"
}

Edit:

My simplified question would be this: Is there an endpoint that comes with @EnableAuthorizationServer, and it works as I am imagining it? You provide a username and a password, and it returns an access_token and a refresh_token.


Solution

  • The answer is yes the endpoint is POST /oauth/token With parameters :

    username -> YOUR_USERNAME
    password -> YOUR_PASSWORD
    grant_type -> password
    

    The clientId and the secret must be send in the Authorization header.