Skip to content

Device authorization codes request should include client_secret #1041

Description

@danielFesenmeyer

Currently, the device authorization codes request does not include the client_secret parameter (aka apiKey).

The OAuth 2.0 Device Grant RFC states [1]:

The client authentication requirements of Section 3.2.1 of [RFC6749] apply to requests on this endpoint, which means that confidential clients (those that have established client credentials) authenticate in the same manner as when making requests to the token endpoint...

Hence, the method OAuth20Service#createDeviceAuthorizationCodesRequest(String) should not only set the client_id, but also the client_secret here [2].
Imho the line
request.addParameter(OAuthConstants.CLIENT_ID, getApiKey());
should be replaced with:
api.getClientAuthentication().addClientAuthentication(request, getApiKey(), getApiSecret());

I observed this issue when trying to test device authorization with a confidential Keycloak client - I got a Keycloak response 401 with body:
{"error":"unauthorized_client","error_description":"Client secret not provided in request"}

[1] https://datatracker.ietf.org/doc/html/rfc8628#section-3.1
[2]

request.addParameter(OAuthConstants.CLIENT_ID, getApiKey());

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions