Description
Description
Unable to use auth_bearer
option in HttpClient
with Login with Amazon access token.
How to reproduce
The problem is that a Login with Amazon access token contains the following character |
which is not from the base64 alphabet.
In order to reproduce you just need to pass a token like this:
$response = $httpClient->request('GET', '/user/profile', [
'auth_bearer' => 'Atza|IwEBIP_aN-yCg-udSr1lQvXHMzVwobs...', // Note that this is not the full token
]);
The error is pretty straightforward:
Option "auth_bearer" must be a string containing only characters from the base 64 alphabet, invalid string given.
Possible Solution
Allow the |
character in the regex defined in HttpClientTrait
with something like '{^[-._=~+/|0-9a-zA-Z]++$}'
or allow to pass an option to disable this check.
Additional context
An example token looks like the following:
Atza|IwEBIP_aN-yCg-udSr1lQvXHMzVwobsXt23OYs9ipZHq26ccXPZkR889oP5R7jKWs36f5Si63wlZX-7ijWek97vv8eygxGXExy3M7cGp959U98Z...
I know that the easiest solution to this problem is to use the Authorization
header and forget about it. But I secretly want to allow tokens with the |
character. Why do we need this check anyways?
$response = $httpClient->request('GET', '/user/profile', [
'headers' => [
'Authorization' => 'Bearer Atza|IwEBIP_aN-yCg-udSr1lQvXHMzVwobs...', // Note that this is not the full token
],
]);
If one of the provided solutions is okay I want to make a PR.