You are here

public function InstagramAccount::getOauthUrl in Instagram Feeds 8

Gets URL to Instagram Auth form.

Return value

\Drupal\Core\Url Url to Instagram Auth form.

Overrides InstagramAccountInterface::getOauthUrl

File

src/Entity/InstagramAccount.php, line 309

Class

InstagramAccount
Defines the instagram_account entity class.

Namespace

Drupal\instagram_feeds\Entity

Code

public function getOauthUrl($client_id) : Url {
  $url = self::INSTAGRAM_API_ENDPOINT . '/oauth/authorize?' . http_build_query([
    'client_id' => $client_id,
    'redirect_uri' => Url::fromRoute('entity.instagram_account.add_form')
      ->setAbsolute()
      ->toString(),
    'scope' => 'user_profile,user_media',
    'response_type' => 'code',
  ]);
  return Url::fromUri($url);
}