oauth2-server-php icon indicating copy to clipboard operation
oauth2-server-php copied to clipboard

getAccessTokenData() Returns NULL Despite Valid Token Data

Open reymarkdivino opened this issue 10 months ago • 0 comments

Title:

getAccessTokenData() Returns NULL Despite Valid Token Data

Description:

I'm experiencing an issue with the getAccessTokenData() function where it returns NULL even when there are valid values in the $token variable.

Steps to Reproduce:

  1. Call the getAccessTokenData() method with a valid request and response.
  2. Ensure that the token parameter is correctly retrieved and the token exists in the storage.
  3. Observe that the function returns NULL instead of the expected token data.

Expected Behavior:

The function should return the access token data as an array when provided with a valid token.

Actual Behavior:

The function returns NULL, which prevents further processing.

Code Snippet:

Here’s the relevant part of the code for reference: bshaffer\oauth2-server-php\src\OAuth2\Controller\ResourceController.php

public function getAccessTokenData(RequestInterface $request, ResponseInterface $response)
{
    // Existing logic...
    if ($token_param = $this->tokenType->getAccessTokenParameter($request, $response)) {
        // Check token validity...
        return $token; // This should return the token if valid
    }
    // Additional logic...
    return null;
}

Suggested Fix:

In the updated version of the function, ensure that the return statement at the end is modified to return $token ?? null; to correctly handle the case when the token is valid.

Please let me know if you need any additional information or further assistance!

reymarkdivino avatar Feb 24 '25 05:02 reymarkdivino