Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to override access token request headers #603

Merged

Conversation

JasonTolliver
Copy link
Contributor

This moves the currently hardcoded getAccessTokenResponse into their own method. This allows children providers to construct their own headers as needed.

A perfect example of the necessity of this feature is the newer Pinterest v5 API. In order to exchange the code for an access token, they require an Authorization header composed of a base64 encoded client_id and client_secret. Without this change, the Pinterest Provider would need to entirely reimplement the getAccessTokenResponse method. With this change, the Pinterest Provider could simply:

protected function getTokenHeaders()
{
    return array_merge(
        parent::getTokenHeaders(),
        [
            'Authorization' => 'Basic ' . base64_encode("{$this->clientId}:{$this->clientSecret}"),
        ]
    );
}

JasonTolliver and others added 2 commits August 19, 2022 11:53
This moves the currently hardcoded `getAccessTokenResponse` into their own method.  This allows children providers to construct their own headers as needed.

A perfect example of the necessity of this feature is the newer Pinterest v5 API.  In order to exchange the code for an access token, they require an `Authorization` header composed of a base64 encoded `client_id` and `client_secret`.  Without this change, the Pinterest Provider would need to entirely reimplement the `getAccessTokenResponse` method.  **With** this change, the Pinterest Provider could simply:

```php
protected function getTokenHeaders()
{
    return array_merge(
        parent::getTokenHeaders(),
        [
            'Authorization' => 'Basic ' . base64_encode("{$this->clientId}:{$this->clientSecret}"),
        ]
    );
}
```
@taylorotwell taylorotwell merged commit ce8b2f9 into laravel:5.x Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants