Credentials for Static Access Token
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- php
- Domain
- authentication
Research direction
The issue names FetchAuthTokenInterface and proposes StaticTokenCredentials, but gives no repository file or test entry point. Start by locating existing FetchAuthTokenInterface implementations and credential tests, then compare how token expiry and cache keys are handled. Done should establish whether static-token credentials are supported and, if so, cover the proposed authentication behavior.
Written by the indexing model from the issue text.
Description
I am creating this to see if it would be useful for anyone, as I have run into an instance where it would be nice (for testing). We have removed the accessToken option from our client libraries, so if you have a static access token, there's no way for you to easily provide it in order to authenticate. This may be by design, as it's better to set up appropriate credentials flows instead. However, we could add a Credential class like this for dev/testing:
use Google\Auth\FetchAuthTokenInterface;
class StaticTokenCredentials implements FetchAuthTokenInterface
{
private string $accessToken;
public function __construct(string $accessToken)
{
$this->accessToken = $accessToken;
}
/**
* Return the supplied access token.
*/
public function fetchAuthToken(callable $httpHandler = null): array
{
return [
'access_token' => $this->accessToken,
'expires_in' => 3600, // Customize if you know the exact TTL
];
}
public function getCacheKey(): ?string
{
// Unique key to prevent collision if tokens change
return 'static_token_' . md5($this->accessToken);
}
public function getLastReceivedToken(): ?array
{
return [
'access_token' => $this->accessToken,
];
}
}
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 464
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 103
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from googleapis/google-cloud-php
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
googleapis/google-cloud-php#9730 ·
-
type: feature request
Difficulty 1/5 Under an hour Newbie friendliness 75/100
googleapis/google-cloud-php#9716 · 11 reactions ·
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
googleapis/google-cloud-php#9725 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
googleapis/google-cloud-php#9675 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
googleapis/google-cloud-php#9674 · 1 comment ·
All issues in googleapis/google-cloud-php
Similar issues
-
tooling
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
UX
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ProfessionalWiki/NeoWiki#1525 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
OpenConext/OpenConext-engineblock#2122 ·
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Automattic/safe-publish#594 ·