/** * Twitter connect */ public function connectTwitter() { if (!empty($_GET['oauth_token'])) { $token = $this->session->retrieveAccessToken('Twitter'); // This was a callback request from twitter, get the token $this->service->requestAccessToken($_GET['oauth_token'], $_GET['oauth_verifier'], $token->getRequestTokenSecret()); // Send a request now that we have access token $result = json_decode($this->service->request('account/verify_credentials.json'), true); return $result; } elseif (isset($_GET['denied'])) { $denied = $_GET['denied']; return compact('denied'); } else { // extra request needed for oauth1 to request a request token :-) $token = $this->service->requestRequestToken(); $url = $this->service->getAuthorizationUri(array('oauth_token' => $token->getRequestToken())); header('Location: ' . $url); } }
/** * Redirect to the authorization page for the service * * @param string $provider The name of the service * @param string|null $callbackUrl The URL to be used for the credentials * @param array|null $scope The scope of the access (OAuth2 only) * @return \Illuminate\Http\RedirectResponse */ public function authorizationRedirect($provider, $callbackUrl = null, array $scope = null) { $this->service = $this->provider($provider, $callbackUrl, $scope); if (is_a($this->service, '\\OAuth\\OAuth1\\Service\\AbstractService')) { $token = $this->service->requestRequestToken(); $url = $this->service->getAuthorizationUri(array('oauth_token' => $token->getRequestToken())); } elseif (is_a($this->service, '\\OAuth\\OAuth2\\Service\\AbstractService')) { $url = $this->service->getAuthorizationUri(); } return Redirect::to((string) $url); }
/** * Returns the url to redirect to for authorization purposes. * * @param array $additionalParameters * * @return UriInterface */ public function getAuthorizationUri(array $additionalParameters = array()) { return $this->provider->getAuthorizationUri($additionalParameters); }
/** * @return string */ public function getAuthorizationUri() : string { $url = $this->service->getAuthorizationUri(); return $url->__toString(); }