Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Credentials for Static Access Token

Open
#9,678 0 comments 0 reactions 0 assignees View on GitHub

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

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from googleapis/google-cloud-php

All issues in googleapis/google-cloud-php

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.