Skip to content

How to use refresh token to generate a new access token? #8

@russback

Description

@russback

Question

I'm using a Salesforce provider and although there is no expiry on the saved token, the session is timing out:

{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}

So I am looking at the Auth::$plugin->getTokens()->refreshToken() method to get a new access token. However this doesn't seem to make a call to the provider to get a new token and instead seems to just update the existing token record

    public function refreshToken(Token $token, OAuth1Token|OAuth2Token $accessToken): bool
    {
        $token->accessToken = $accessToken->getToken();
        $token->expires = $accessToken->getExpires();
        
        if ($accessToken->getRefreshToken()) {
            $token->refreshToken = $accessToken->getRefreshToken();
        }

        // Ensure that we update the token's access token with new values for the next request
        $token->setToken($accessToken);

        return $this->saveToken($token);
    }

Am I missing something here?

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions