2

Why do we need to ask the authorization server for theAuthorization code and then exchange the Authorization code for anAccess token on the same server? Why not to return anAccess token directly, without issuing anAuthorization code? I do understand that it is specified by the standard but there should be some logic behind this.

2

The way the “authorization code grant type” is meant to be implemented is in a web app that has public and confidential clients. The authorization code is authorized by the resource owner and the browser (public client) redirects the application to the callback URL, passing the authorization code in the URL parameters. Because the browser is a public client we should not expose the token here. Instead, the (confidential) backend of our webapp, passes that authorization code as well as client_secret to the authorization server and exchanges it for the token.

Do you see how we protect the token and api client_secret by keeping that workflow in the backend?

| improve this answer | |
  • Thank you very much! Now I understand why we pass authorization code instead of access token – Oleksandr Jan 15 at 15:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.