Skip to content

The scope parameter has been mistakenly required on device access token request #1411

Closed
@hafezdivandari

Description

@hafezdivandari

On device authorization flow, according to RFC8628, the "Device Access Token Request" should send these parameters:

  • grant_type
  • device_code
  • client_id

As you can see there is no scope parameter, because the scope parameter had been sent on the first step "Device Authorization Request":

  • client_id
  • scope

The scopes are requested by the client on the first request and should be persisted on the DB. When user enters the user code we display the client info and list of scopes to be approved by user. So the client shouldn't specify scopes on the last request, but the current implementation requires scopes on DeviceCodeGrant::respondToAccessTokenRequest() mistakenly:

$scopes = $this->validateScopes($this->getRequestParameter('scope', $request, $this->defaultScope));
$deviceCodeEntity = $this->validateDeviceCode($request, $client);

I think you should get the scopes from $deviceCodeEntity instead, which was persisted on the DB.

-$scopes = $this->validateScopes($this->getRequestParameter('scope', $request, $this->defaultScope));
$deviceCodeEntity = $this->validateDeviceCode($request, $client);
+$scopes = $deviceCodeEntity->getScopes(); // no need to call `validateScope` because already done on `respondToDeviceAuthorizationRequest` before persisting to DB

Am I missing something?

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