You are here

public function GoogleAnalyticsCounterFeed::createAuthUrl in Google Analytics Counter 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 for Web application from Google API Console.

string $redirect_uri: Callback url.

Return value

string The url to authorize.

1 call to GoogleAnalyticsCounterFeed::createAuthUrl()
GoogleAnalyticsCounterFeed::beginAuthentication in src/GoogleAnalyticsCounterFeed.php
Redirect to Google authentication page.

File

src/GoogleAnalyticsCounterFeed.php, line 135

Class

GoogleAnalyticsCounterFeed
Authorize access and request data from Google Analytics Core Reporting API.

Namespace

Drupal\google_analytics_counter

Code

public function createAuthUrl($client_id, $redirect_uri) {
  $params = [
    'response_type=code',
    'redirect_uri=' . $redirect_uri,
    'client_id=' . urlencode($client_id),
    'scope=' . self::SCOPE,
    'access_type=offline',
    'approval_prompt=force',
  ];
  $params = implode('&', $params);
  return self::OAUTH2_AUTH_URL . "?{$params}";
}