KnpLabs / KnpLabs/php-github-api
Get release asset end in AccessDenied
- Dominant language
- PHP
- Stars
- 2.2k
- Forks
- 587
- PR merge metrics
- No merged PRs in 30d
Description
With the GuzzleHTTP\Client it's not possible to load assets as binary, the redirect to https://objects.githubusercontent.com/ returns an error:
```php
$token = 'example';
$client = Client::createWithHttpClient( new \GuzzleHttp\Client() );
$client->authenticate( $token, Client::AUTH_ACCESS_TOKEN );
$content = $this->client->repo()->releases()->assets()->show( $username, $name, $assetId, true );
$temp = tempnam( sys_get_temp_dir(), 'TMP_' );
file_put_contents( $temp, $content );
```
```xml
AccessDenied
Multiple auth mechanisms are not allowed; please use either query parameters or an Authorization header
github-production-release-asset-XXXXX
```
With the HttpClient\HttplugClient from Symfony it works:
```php
...
$client = Client::createWithHttpClient( new \Symfony\Component\HttpClient\HttplugClient() );
$client->authenticate( $token, Client::AUTH_ACCESS_TOKEN );
...
```
The redirect-plugin uses the same client which appends the Authorization-header to the request, but the redirect-URL already contains query-parameter for authentication.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing releases()->assets()->show(..., true) through the redirect handling used with GuzzleHttp\Client, comparing it with Symfony's HttplugClient. Reproduce the redirect to objects.githubusercontent.com and verify that the release asset downloads without sending both the Authorization header and query authentication parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100