@param $preAuthCode
@param $sessionInfo

@return \EntWeChat\Support\Collection
18318
public function setAuthorizerOption($preAuthCode, $sessionInfo)
    {
        $params = [
            'pre_auth_code' => $preAuthCode,
            'session_info'  => $sessionInfo,
        ];

        return $this->parseJSON('json', [self::SET_SESSION_INFO, $params]);
    }
1154434
public function authenticate($code)
    {
        if (empty($code)) {
            throw new NostoException('Invalid authentication token');
        }

        $request = new HttpRequest();
        $request->setUrl(Nosto::getOAuthBaseUrl() . self::PATH_TOKEN);
        $request->setReplaceParams(
            array(
                '{cid}' => $this->clientId,
                '{sec}' => $this->clientSecret,
                '{uri}' => $this->redirectUrl,
                '{cod}' => $code
            )
        );
        $response = $request->get();
        $result = $response->getJsonResult(true);

        if ($response->getCode() !== 200) {
            throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response);
        }
        if (empty($result['access_token'])) {
            throw new NostoException('No "access_token" returned after authenticating with code');
        }
        if (empty($result['merchant_name'])) {
            throw new NostoException('No "merchant_name" returned after authenticating with code');
        }

        return NostoOAuthToken::create($result);
    }
1125696
public function setAuthenticationInfo($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Audit\AuthenticationInfo::class);
        $this->authentication_info = $var;

        return $this;
    }
1167433
public function createPreAuthCode($identification)
    {
        $cacheKey = sprintf($this->preAuthCodeCacheKey, $identification);

        return Cache::get($cacheKey, function () use ($cacheKey) {
            $response = $this->http->jsonPost(self::API_CREATE_PREAUTHCODE, [
                'component_appid' => $this->appid,
            ]);

            $pre_auth_code = $response['pre_auth_code'];

            // 把pre_auth_code缓存起来
            $expiresAt = Carbon::now()->addSeconds($response['expires_in']);
            Cache::put($cacheKey, $pre_auth_code, $expiresAt);

            return $pre_auth_code;
        });
    }
247036
public function getBySession(SessionEntity $session)
    {
        $result = $this->getConnection()->table('oauth_clients')
                ->select(
                    'oauth_clients.id as id',
                    'oauth_clients.secret as secret',
                    'oauth_clients.name as name')
                ->join('oauth_sessions', 'oauth_sessions.client_id', '=', 'oauth_clients.id')
                ->where('oauth_sessions.id', '=', $session->getId())
                ->first();

        if (is_null($result)) {
            return;
        }

        return $this->hydrateEntity($result);
    }
946575
public function getAuthorizerInfo($authorizerCorpId, $permanentCode)
    {
        $params = [
            'suite_id'       => $this->getSuiteId(),
            'auth_corpid'    => $authorizerCorpId,
            'permanent_code' => $permanentCode,
        ];

        return $this->parseJSON('json', [self::GET_AUTH_INFO, $params]);
    }
986522
protected  function requestUserInfo() {
        $res = $this->sendRequest('GET', $this->getUrl('oauth', 'userinfo'), array(), array(
            'Authorization' => 'Bearer ' . $this->sessionStorage->read('access_token'),
        ));
        $result = $res->getBody();

        return json_decode($result, true);
    }
874810
public function refreshSessionInfo( SessionInfo $info, WebRequest $request, &$metadata ) {
		if ( $metadata === null ) {
			$metadata = [];
		}

		$this->logger->info( "Setting up auto login session for remote user name " .
			"'{remoteUserName}' (mapped to MediaWiki user '{canonicalUserName}', " .
			"currently active as MediaWiki user '{canonicalUserNameUsed}').",
			$metadata
		);

		$disableSpecialPages = [];
		$disablePersonalUrls = [];
		$preferences = ( $this->userPrefsForced ) ? $this->userPrefsForced : [];

		# Disable any special pages related to user switching.
		if ( !$this->switchUser ) {
			$disableSpecialPages += [
				'Userlogin' => true,
				'Userlogout' => true,
				'LinkAccounts' => true,
				'UnlinkAccounts' => true,
				'ChangeCredentials' => true,
				'RemoveCredentials' => true,
			];
			# Special page 'CreateAccount' depends on the `createaccount` permission.
			#
			# If `self::switchUser` is `false` a user with this permission can still
			# access this page and create accounts, but won't be logged-in to the newly
			# created one.
			#
			# Making access to this page dependent on permissions is useful for wikis
			# where only a subset of all remotely authenticated users should become
			# logged-in automatically (when the extension is not configured to create
			# accounts for all users) and user switching is forbidden. A wiki admin with
			# this permission can then access this page to create accounts explicitly.
			$user = $info->getUserInfo()->getUser();
			$permissions = $user->getGroupPermissions( $user->getEffectiveGroups() );
			if ( !in_array( 'createaccount', $permissions, true ) ) {
				$disableSpecialPages += [ 'CreateAccount' => true ];
			}
		}

		# This can only be true, if our `switchUser` member is set to true and the
		# user identified by us uses another local wiki user for this session.
		$switchedUser = ( $info->getUserInfo()->getId() !== $metadata[ 'userId' ] ) ? true : false;

		# Disable password related special pages and hide preference option.
		if ( !$switchedUser ) {
			$disableSpecialPages += [
				'ChangePassword' => true,
				'PasswordReset' => true,
			];
			global $wgHiddenPrefs;
			$wgHiddenPrefs[] = 'password';
		}

		# Redirect to given remote logout url. Either by redirect after a normal
		# logout request to Special:UserLogout or by replacing the url in the logout
		# button when user switching is not allowed and therefore the special page for
		# logout is not accessible.
		#
		# When the special page UserLogout is accessible, then we have to distinguish
		# between internal and external redirects. For internal redirects we have to
		# use the `UserLogout` hook to redirect before the local session/cookie will
		# be deleted. Because with this session provider in place we would login the
		# user with the next request again anyway (so no need to destroy the session).
		# For external redirects we must delete the local session/cookie first,
		# therefore we use the `UserLogoutComplete` hook for these type of urls.
		if ( $this->userUrls && isset( $this->userUrls[ 'logout' ] ) ) {
			$url = $this->userUrls[ 'logout' ];
			if ( $this->canChangeUser() ) {
				Hooks::register(
					'UserLogout',
					function() use ( $url, $metadata, $switchedUser ) {
						if ( $url instanceof Closure ) {
							$url = call_user_func( $url, $metadata );
						}
						$internal = Title::newFromText( $url );
						$known = $internal && $internal->isKnown();
						if ( $known ) {
							$url = $internal->getFullURL();
						}
						if ( $known && !$switchedUser ) {
							# Inhibit redirect loop.
							if ( !preg_match( '#[/=]Special:UserLogout([/?&].*)?$#', $url ) ) {
								global $wgOut;
								$wgOut->redirect( $url );
							}
							return false;
						}
						Hooks::register(
							'UserLogoutComplete',
							function() use ( $url ) {
								global $wgOut;
								$wgOut->redirect( $url );
								return true;
							}
						);
						return true;
					}
				);
			} else {
				Hooks::register(
					'PersonalUrls',
					function( &$personalurls ) use ( $url, $metadata ) {
						if ( $url instanceof Closure ) {
							$url = call_user_func( $url, $metadata );
						}
						$internal = Title::newFromText( $url );

						if ( $internal && $internal->isKnown() ) {
							$url = $internal->getLinkURL();
						}
						$personalurls[ 'logout' ] = [
							'href' => $url,
							'text' => wfMessage( 'pt-userlogout' )->text(),
							'active' => false
						];
						return true;
					}
				);
			}
		} elseif ( !$switchedUser ) {
			$disablePersonalUrls += [ 'logout' => true ];
		}

		# Set user preferences on account creation only.
		if ( !$info->getUserInfo()->getId() ) {
			$prefs = $preferences;
			if ( $this->userPrefs ) {
				$prefs += $this->userPrefs;
			}
			Hooks::register(
				'LocalUserCreated',
				function( $user, $autoCreated ) use ( $prefs, $metadata ) {
					if ( $autoCreated ) {
						$this->setUserPrefs(
							$user,
							$prefs,
							$metadata
						);
					}
				}
			);
		}

		# Set user preferences on each request.
		#
		# Forcing user preferences is useful if they are provided by an external
		# source and must not be changed by the user himself.
		#
		# @see $wgGroupPermissions['user']['editmyoptions']
		if ( !$switchedUser && count( $preferences ) ) {

			$this->setUserPrefs(
				$info->getUserInfo()->getUser(),
				$preferences,
				$metadata,
				true
			);

			# Disable special pages related to email preferences.
			if ( array_key_exists( 'email', $preferences ) ) {
				$disableSpecialPages += [
					'ChangeEmail' => true,
					'Confirmemail' => true,
					'Invalidateemail' => true,
				];
			}

			# Do not hide forced preferences completely by using the global
			# `$wgHiddenPrefs`, because we still want them to be shown to the user.
			# Therefore use the according hook to disable their editing capabilities.
			$keys = array_keys( $preferences );
			Hooks::register(
				'GetPreferences',
				function( $user, &$prefs ) use ( $keys ) {
					foreach( $keys as $key ) {

						if ( 'email' === $key ) {
							$key = 'emailaddress';
						}

						if ( !array_key_exists( $key, $prefs ) ) {
							continue;
						}

						# Email preference needs special treatment, because it will display a
						# link to change the address. We have to replace that with the address
						# only.
						if ( 'emailaddress' === $key ) {
							$prefs[ $key ][ 'default' ] = $user->getEmail() ?
								htmlspecialchars( $user->getEmail() ) : '';
						}

						$prefs[ $key ][ 'disabled' ] = 'disabled';

					}
				}
			);
		}

		# Don't remove anything.
		if ( !$this->removeAuthPagesAndLinks ) {
			$disableSpecialPages = [];
			$disablePersonalUrls = [];
		}

		Hooks::register(
			'SpecialPage_initList',
			function ( &$specials ) use ( $disableSpecialPages ) {
				foreach ( $disableSpecialPages as $page => $true ) {
					if ( $true ) { unset( $specials[ $page ] ); }
				}
				return true;
			}
		);

		Hooks::register(
			'PersonalUrls',
			function ( &$personalurls ) use ( $disablePersonalUrls ) {
				foreach ( $disablePersonalUrls as $url => $true ) {
					if ( $true ) { unset( $personalurls[ $url ] ); }
				}
				return true;
			}
		);

		# Before running the hook, prepare the session by mirroring the steps
		# normally performed by the AuthManager.
		#
		# @see AuthManager::setSessionDataForUser()
		# @see AuthManager::securitySensitiveOperationStatus()
		if ( $this->callUserLoggedInHook ) {

			$session = $this->manager->getSessionFromInfo( $info, $request );
			$delay = $session->delaySave();
			$session->resetAllTokens();
			$session->set( 'AuthManager:lastAuthId', $info->getUserInfo()->getId() );
			$session->set( 'AuthManager:lastAuthTimestamp', time() );
			$session->persist();
			# Destroy scoped callback.
			#
			# @see \ScopedCallback::consume() for MW REL1.27
			# @see \Wikimedia\ScopedCallback::consume() for MW >=REL1.28
			$delay = null;

			Hooks::run( 'UserLoggedIn', [ $info->getUserInfo()->getUser() ] );

		}

		return true;
	}
1113386
public function getAuthorization(string $authCorpId, string $permanentCode)
    {
        $params = [
            'auth_corpid' => $authCorpId,
            'permanent_code' => $permanentCode,
        ];

        return $this->httpPostJson('cgi-bin/service/get_auth_info', $params);
    }
907997
public function getWidgetRegisterSession($sessionToken)
    {
        $widgetRegisterSession = $this->factory->createEmptyWidgetRegisterSession();
        $widgetRegisterSession->populate($sessionToken);

        return $widgetRegisterSession;
    }
791703
public function requestAccessToken($callbackUri, $authorizationCode)
    {
        $params = array(
            'client_id' => $this->appId,
            'client_secret' => $this->appSecret,
            'code' => $authorizationCode,
            'grant_type' => 'authorization_code',
            'redirect_uri' => $callbackUri,
            'response_type' => 'code',
            'scope' => $this->scope,
            'strict' => $this->strictChecks,
        );

        $url = sprintf('%s%s', $this->endpoint, $this->paths['access_token']);

        $this->logger->info(sprintf("Requesting AccessToken to '%s'", $url));
        $this->logger->debug(sprintf('Sent params: %s', json_encode($params)));

        $response = $this->browser->submit($url, $params);

        $this->logger->debug(sprintf('Response of AccessToken: %s', $response));

        $content = $response->getContent();
        $response = json_decode($content, true);

        if (null === $response) {
            $this->logger->error('Received non-json response.', array('response' => $content));

            throw new OAuthException('provider', "Response content couldn't be converted to JSON.");
        }

        if (isset($response['error'])) {
            $this->logger->error('The OAuth2 provider responded with an error', array('response' => $response));

            $error = $response['error'];
            $message = $response['message'];

            throw new OAuthException($error, $message);
        }

        $token = $response['access_token'];
        $scope = $response['scope'];

        return array('access_token' => $token, 'scope' => $scope);
    }
1060501
public function sessionInfo($sessionId)
    {
        $xml = new DOMDocument();
        $transaction = $xml->createElement('hps:Transaction');
        $info = $xml->createElement('hps:AltPaymentSessionInfo');

        $info->appendChild($xml->createElement('hps:TransactionType', $this->_transactionType));
        $info->appendChild($xml->createElement('hps:SessionId', $sessionId));

        $transaction->appendChild($info);
        return $this->_submitTransaction($transaction, 'AltPaymentSessionInfo');
    }
10694
public function setUserInfo( $userInfo )
    {
        $userInfoParts = explode( ":", $userInfo );
        $this->user = $userInfoParts[0];
        $this->password = $userInfoParts[1];

        return $this;
    }
376097
public GetOauthUserInfoResponse getOauthUserInfo(String code){
        if(StrUtil.isBlank(code)){
            throw new NullPointerException("code is null");
        }
        GetOauthUserInfoResponse response;
        String url = BASE_API_URL + "cgi-bin/user/getuserinfo?access_token=#&code=" + code;
        BaseResponse r = executeGet(url);
        String jsonResult = isSuccess(r.getErrcode()) ? r.getErrmsg() : r.toJsonString();
        response = JSONUtil.toBean(jsonResult, GetOauthUserInfoResponse.class);
        return response;
    }
942535
public function getAccessToken(string $session_token):AccessToken{

		$params = [
			'method'  => 'auth.getSession',
			'format'  => 'json',
			'api_key' => $this->options->key,
			'token'   => $session_token,
		];

		$params['api_sig'] = $this->getSignature($params);

		$request = $this->requestFactory
			->createRequest('GET', Psr7\merge_query($this->apiURL, $params));


		return $this->parseTokenResponse($this->http->sendRequest($request));
	}
1105922
public function enquiry($preApprovalCode, HandlerStack $stack = null)
    {
        try {
            $params = $this->generateParams(['preApprovalCode' => $preApprovalCode], $stack);

            $result = $this->getClient()->post('preapprovals/enquire', $params);

            return $this->getSerializer()->deserialize(
                (string) $result->getBody(),
                Model\InStore\PreApproval::class,
                'json'
            );
        } catch (BadResponseException $exception) {
            throw new ApiException(
                $this->getSerializer()->deserialize(
                    (string) $exception->getResponse()->getBody(),
                    Model\ErrorResponse::class,
                    'json'
                ),
                $exception
            );
        }
    }
131021
public function getAuthorizationCode($code)
    {
        $sql  = sprintf('SELECT * from %s where authorization_code = :code', $this->config['code_table']);
        $code = $this->fetch($sql, compact('code'));
        if ($code) {
            // convert date string back to timestamp
            $code['expires'] = strtotime($code['expires']);
        }

        return $code;
    }