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

Breadcrumb

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

function GitLab::createToken

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::createToken()
GitLab::authorizeOAuthInteractively 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 239

Class

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

Namespace

Composer\Util

Code

private function createToken(string $scheme, string $originUrl) : array {
    $username = $this->io
        ->ask('Username: ');
    $password = $this->io
        ->askAndHideAnswer('Password: ');
    $headers = [
        'Content-Type: application/x-www-form-urlencoded',
    ];
    $apiUrl = $originUrl;
    $data = http_build_query([
        'username' => $username,
        'password' => $password,
        'grant_type' => 'password',
    ], '', '&');
    $options = [
        'retry-auth-failure' => false,
        'http' => [
            'method' => 'POST',
            'header' => $headers,
            'content' => $data,
        ],
    ];
    $token = $this->httpDownloader
        ->get($scheme . '://' . $apiUrl . '/oauth/token', $options)
        ->decodeJson();
    $this->io
        ->writeError('Token successfully created');
    return $token;
}

API Navigation

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