Hook to alter request options on retrieve tokens method

Created on 14 July 2020, over 4 years ago
Updated 9 June 2023, over 1 year ago

I need to add 'Authorization' => 'basic' to the HTTP request header in the retrieveTokens method in OpenIDConnectClientBase.php. In addition, my 'Authorization' will receive the base64 value from client_id concatenated with client_secret.

Would it be possible to make these changes via hook?

I'm sorry, if I'm posting a question without much foundation or an easy solution, I'm starting with the development of Drupal 8/9.
Here is the code I need to change/add on retrieveTokens method:

    $client_concat = $this->configuration['client_id'] . ':' . $this->configuration['client_secret'];
    $client_hash = base64_encode($client_id_secret_concat);

    $request_options = [
      'form_params' => [
        'code' => $authorization_code,
        'client_id' => $this->configuration['client_id'],
        'client_secret' => $this->configuration['client_secret'],
        'redirect_uri' => $redirect_uri,
        'grant_type' => 'authorization_code',
      ],
      'headers' => [
        'Accept' => 'application/json',
        'Authorization' => 'basic ' . $client_hash,
      ],
    ];

Sorry for my english and thank you

💬 Support request
Status

Fixed

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇫🇷France pacproduct

    I'm facing this exact same issue too, maybe this should be an option?

    @rogeriocc Would you care to share how you solved it with some code examples? :)

Production build 0.71.5 2024