Search code examples
oauth-2.0

A question about oauth2.0 client_secret when exchanging authorization code for token


https://www.rfc-editor.org/rfc/rfc6749#section-4.1.3 """ The client makes a request to the token endpoint by sending the following parameters using the "application/x-www-form-urlencoded" format per Appendix B with a character encoding of UTF-8 in the HTTP request entity-body:

grant_type REQUIRED. Value MUST be set to "authorization_code".

code REQUIRED. The authorization code received from the authorization server.

redirect_uri REQUIRED, if the "redirect_uri" parameter was included in the authorization request as described in Section 4.1.1, and their values MUST be identical.

client_id REQUIRED, if the client is not authenticating with the authorization server as described in Section 3.2.1.

If the client type is confidential or the client was issued client credentials (or assigned other authentication requirements), the client MUST authenticate with the authorization server as described in Section 3.2.1. """

client_secret is not in the param list, why?


Solution

  • If client type is public than client secret does not exist. Read section 3.2.1 and then section 2.1.

    Confidential clients are typically issued (or establish) a set of
    client credentials used for authenticating with the authorization
    server (e.g., password, public/private key pair).

    So for confidential clients one more parameter is required. In Keycloak or IdentityServer4 that parameter is client_secret.