You are here

public function GoogleAnalyticsReportsApiFeed::createAuthUrl in Google Analytics Reports 8.3

Create a URL to obtain user authorization.

The authorization endpoint allows the user to first authenticate, and then grant/deny the access request.

Parameters

string $client_id: Client id.

string $redirect_uri: Redirect uri.

Return value

string Generated url.

1 call to GoogleAnalyticsReportsApiFeed::createAuthUrl()
GoogleAnalyticsReportsApiFeed::beginAuthentication in google_analytics_reports_api/src/GoogleAnalyticsReportsApiFeed.php
Begin authentication.

File

google_analytics_reports_api/src/GoogleAnalyticsReportsApiFeed.php, line 236

Class

GoogleAnalyticsReportsApiFeed
Class GoogleAnalyticsReportsApiFeed.

Namespace

Drupal\google_analytics_reports_api

Code

public function createAuthUrl($client_id, $redirect_uri) {
  $query = [
    'response_type' => 'code',
    'redirect_uri' => $redirect_uri,
    'client_id' => urlencode($client_id),
    'scope' => self::SCOPE,
    'access_type' => 'offline',
    'approval_prompt' => 'force',
  ];
  return Url::fromUri(self::OAUTH2_AUTH_URL, [
    'query' => $query,
  ])
    ->toString();
}