Gets the current OAuth application.
@return \React\Promise\ExtendedPromiseInterface
773645
function getCurrentApplication() {
        $url = \CharlotteDunois\Yasmin\HTTP\APIEndpoints::ENDPOINTS['currentOAuthApplication'];
        return $this->api->makeRequest('GET', $url, array());
    }
923973
public function linkAccountCallback() {
    $sdk = $this->getSdk();

    if ($sdk instanceof RedirectResponse) {
      return $sdk;
    }

    $this->authManager->setSdk($sdk);

    // Get the OAuth token from Google.
    if (!$this->authManager->getAccessToken('link')) {
      drupal_set_message($this->t('@network login failed. Token is not valid.', [
        '@network' => $this->t('Google'),
      ]), 'error');
      return $this->redirect('entity.user.edit_form', [
        'user' => $this->currentUser()->id(),
      ]);
    }

    // Get user's Google profile from Google API.
    if (!($profile = $this->authManager->getProfile()) || !($account_id = $profile->getId())) {
      drupal_set_message($this->t('@network login failed, could not load @network profile. Contact site administrator.', [
        '@network' => $this->t('Google'),
      ]), 'error');
      return $this->redirect('entity.user.edit_form', [
        'user' => $this->currentUser()->id(),
      ]);
    }

    // Check whether any another user account already connected.
    $account = $this->entityTypeManager()
      ->getStorage('user')
      ->loadByProperties(['google_id' => $account_id]);
    $account = current($account);

    // Check whether another account was connected to this Google account.
    if ($account && (int) $account->id() !== (int) $this->currentUser()->id()) {
      drupal_set_message($this->t('Your @network account has already connected to another account on this site.', [
        '@network' => $this->t('Google'),
      ]), 'warning');
      return $this->redirect('entity.user.edit_form', [
        'user' => $this->currentUser()->id(),
      ]);
    }

    $account = User::load($this->currentUser()->id());
    $account->get('google_id')->setValue($account_id);
    $account->save();

    drupal_set_message($this->t('You are now able to log in with @network', [
      '@network' => $this->t('Google'),
    ]));
    return $this->redirect('entity.user.edit_form', [
      'user' => $account->id(),
    ]);
  }
57503
protected function getToken()
    {
        $temp = $this->request->getSession()->get('oauth.temp');

        return $this->server->getTokenCredentials(
            $temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
        );
    }
296352
public function getAuthenticationClient()
    {
        if (null === $this->authenticationClient) {
            $this->authenticationClient = new Auth\OAuth2(
                $this->getHttpClient(),
                $this->getOption('client_id'),
                $this->getOption('client_secret')
            );
        }

        return $this->authenticationClient;
    }
441510
public function getOAuthToken()
    {
        if (!$this->isStateless()) {
            return \Cache::get('oauth.temp');
        } else {
            /** @var TemporaryCredentials $temp */
            $temp = unserialize(\Cache::get('oauth_temp'));

            return $temp->getIdentifier();
        }
    }
118416
public function getApplication() {
		if (!is_null($this->session)) {
			return $this->session->getApplication();
		} else {
			return $this->context->getSystem()->getApplication();
		}
	}
720533
protected function getFreshApplication()
    {
        if (method_exists($this->laravel, 'bootstrapPath')) {
            $app = require $this->laravel->bootstrapPath().'/app.php';
        } else {
            $app = require $this->laravel->basePath().'/bootstrap/app.php';
        }

        $app->make(Kernel::class)->bootstrap();

        return $app;
    }
626442
public function getDefaultAuth(): ?Guard
    {
        // By default, the Auth Facade does not return the
        // any actual authentication guard, but rather an
        // instance of \Illuminate\Auth\AuthManager.
        // Therefore, we make sure only to obtain its
        // "default guard", to make sure that its only the guard
        // instance that we obtain.
        $manager = Auth::getFacadeRoot();
        if (isset($manager)) {
            return $manager->guard();
        }
        return $manager;
    }
885052
protected function accessTokenMiddleware()
    {
        return function (callable $handler) {
            return function (RequestInterface $request, array $options) use ($handler) {
                if (!$this->accessToken) {
                    return $handler($request, $options);
                }

                $field = $this->accessToken->getQueryName();
                $token = $this->accessToken->getToken();

                $request = $request->withUri(Uri::withQueryValue($request->getUri(), $field, $token));

                return $handler($request, $options);
            };
        };
    }
44670
public function getOauthAccessToken(){
        $code = isset($_GET['code'])?$_GET['code']:'';
        if (!$code) return false;
        $result = $this->http_get(self::API_BASE_URL_PREFIX.self::OAUTH_TOKEN_URL.'appid='.$this->appid.'&secret='.$this->appsecret.'&code='.$code.'&grant_type=authorization_code');
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            $this->user_token = $json['access_token'];
            return $json;
        }
        return false;
    }
521279
public function getApplication()
    {
        //load drupals autoload.php, so their classes are available
        if (file_exists('./vendor/autoload.php')) {
            $autoloader = require './vendor/autoload.php';
        } else {
            $autoloader = require '../vendor/autoload.php';
        }

        $sitePath = 'sites/default';

        Settings::initialize('./', $sitePath, $autoloader);

        $app = new DrupalKernel($this->appenv, $autoloader);
        $app->setSitePath($sitePath);

        return $app;
    }
590213
public function getMeAction()
    {
        $tokenManager = $this->get('fos_oauth_server.access_token_manager');


        $accessToken = $tokenManager->findTokenByToken(
            $this->get('security.context')->getToken()->getToken()
        );
        /* @var $me UserInterface */
        $me = $accessToken->getUser();

        if (null === $me) {
            throw new NotFoundHttpException('User is null.');
        }
        if (false === $me instanceof UserInterface) {
            throw new NotFoundHttpException('User not found.');
        }

        return new JsonResponse([
            'objectId' => $me->getId()
            , 'userName' => $me->getUsername()]);
    }
581452
public function getAccessToken()
    {
        if (!$this->isStateless) {
            $expectedState = $this->getSession()->get(self::OAUTH2_SESSION_STATE_KEY);
            $actualState = $this->getCurrentRequest()->query->get('state');
            if (!$actualState || ($actualState !== $expectedState)) {
                throw new InvalidStateException('Invalid state');
            }
        }

        $code = $this->getCurrentRequest()->get('code');

        if (!$code) {
            throw new MissingAuthorizationCodeException('No "code" parameter was found (usually this is a query parameter)!');
        }

        return $this->provider->getAccessToken('authorization_code', [
            'code' => $code,
        ]);
    }
1302867
public function getService()
    {
        if (!$this->service) {
            /** @var \OAuth\ServiceFactory $serviceFactory */
            $serviceFactory = $this->app->make('oauth/factory/service');
            $this->service = $this->factory->createService($serviceFactory);
        }

        return $this->service;
    }
547162
public function token()
    {
        $response = $this->oauthServer->handleTokenRequest(Request::createFromGlobals());
        if (!$response->isSuccessful()) {
            return $this->response->sendError(
                ResponseCodes::AUTH_ERROR,
                $response->getStatusCode(),
                $response->getParameter('error_description')
            );
        } else {
            return $this->response->sendSuccess($response->getParameters());
        }
    }
328652
public function getApplication()
    {
        if (!is_object($this->application)) {
            $this->application = Application::init();
        }
        return $this->application;
    }
726002
public function getLoginUrl()
    {
        // required params
        $params = array(
            'client_id' => $this->getClientId(),
            'redirect_uri' => $this->getRedirectUri(),
        );
        // optional params
        if ($this->getScope()) {
            $params['scope'] = implode(',', $this->getScope());
        }
        if ($this->getResponceType()) {
            $params['response_type'] = $this->getResponceType();
        }
        if ($this->apiVersion) {
            $params['v'] = $this->apiVersion;
        }
        if ($this->state) {
            $params['state'] = $this->state;
        }

        return 'https://oauth.vk.com/authorize?' . http_build_query($params);
    }