Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. GitLab.php

function GitLab::refreshToken

Return value

array{access_token: non-empty-string, refresh_token: non-empty-string, token_type: non-empty-string, expires_in: positive-int, created_at: positive-int}

See also

https://docs.gitlab.com/ee/api/oauth2.html#resource-owner-password-cred…

1 call to GitLab::refreshToken()
GitLab::authorizeOAuthRefresh in vendor/composer/composer/src/Composer/Util/GitLab.php
Authorizes a GitLab domain interactively via OAuth.

File

vendor/composer/composer/src/Composer/Util/GitLab.php, line 290

Class

GitLab
@author Roshan Gautam <roshan.gautam@hotmail.com>

Namespace

Composer\Util

Code

private function refreshToken(string $scheme, string $originUrl) : array {
    $authTokens = $this->config
        ->get('gitlab-oauth');
    if (!isset($authTokens[$originUrl]['refresh-token'])) {
        throw new \RuntimeException('No GitLab refresh token present for ' . $originUrl . '.');
    }
    $refreshToken = $authTokens[$originUrl]['refresh-token'];
    $headers = [
        'Content-Type: application/x-www-form-urlencoded',
    ];
    $data = http_build_query([
        'refresh_token' => $refreshToken,
        'grant_type' => 'refresh_token',
    ], '', '&');
    $options = [
        'retry-auth-failure' => false,
        'http' => [
            'method' => 'POST',
            'header' => $headers,
            'content' => $data,
        ],
    ];
    $token = $this->httpDownloader
        ->get($scheme . '://' . $originUrl . '/oauth/token', $options)
        ->decodeJson();
    $this->io
        ->writeError('GitLab token successfully refreshed', true, IOInterface::VERY_VERBOSE);
    $this->io
        ->writeError('To revoke access to this token you can visit ' . $scheme . '://' . $originUrl . '/-/profile/applications', true, IOInterface::VERY_VERBOSE);
    return $token;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal