Credential::getSecretCode

@param \O2System\Security\Authentication\Oauth\Client\Account $client
@param array                                                  $options
339617
public function getSecretCode(Oauth\Client\Account $client, array $options = [])
    {
        $scope = $this->config[ 'scope' ];
        if (isset($options[ 'scope' ])) {
            if (is_array($options[ 'scope' ])) {
                $scope = array_merge($scope, $options[ 'scope' ]);
            }
        }

        $params = [
            'scope'         => $scope,
            'state'         => $this->state,
            'client_id'     => $client->id,
            'redirect_uri'  => $this->redirect_uri,
            'response_type' => $this->response_type,
        ];
    }
1090179
public static function fetchClient($client_id, $client_secret = null)
	{
		$query = DB::table('oauth_clients')->where('id', $client_id);
		if (null !== $client_secret) {
			$query->where('secret', $client_secret);
		}
		$client = $query->first();
		
		if (!$client) {
			return null;
		}
		
		return new Authentication\Client($client_id, (array) $client);
	}
375736
public function getAccessTokenByClientCredentials(array $params = array())
    {
        $params = array(
            'grant_type' => 'client_credentials',
            'client_id' => $this->getClientId(),
            'client_secret'	=> $this->getClientSecret(),
        ) + $params;
        $request = $this->request('GET', 'oauth/2.0/token', $params);
        return $request->response()->getJson(true);
    }
885824
public function getMyCredentials($strategy, array $options = [])
    {
        $options['httpParams'][':strategy'] = $strategy;

        return $this->query($this->buildQueryArgs('auth', 'getMyCredentials'), [], $options)['result'];
    }
475960
public function generateToken($data, $options = array())
    {
        return $this->encodeToken(
            $this->buildClaims($options + array('data' => $data)),
            $this->secret
        );
    }
723361
protected function authOAuth1($client, $authUrlParams = [])
    {
        $request = Yii::$app->getRequest();

        // user denied error
        if ($request->get('denied') !== null) {
            return $this->authCancel($client);
        }

        if (($oauthToken = $request->get('oauth_token', $request->post('oauth_token'))) !== null) {
            // Upgrade to access token.
            $client->fetchAccessToken($oauthToken);
            return $this->authSuccess($client);
        }

        // Get request token.
        $requestToken = $client->fetchRequestToken();
        // Get authorization URL.
        $url = $client->buildAuthUrl($requestToken, $authUrlParams);
        // Redirect to authorization URL.
        return Yii::$app->getResponse()->redirect($url);
    }
626265
public function getAccessToken($grant = 'client_credentials', array $options = [])
    {
        if($this->accessToken !== null) {
            return $this->accessToken;
        }

        return $this->accessToken = $this->issueAccessToken($grant, $options);
    }
751673
public function presign(
        RequestInterface $request,
        CredentialsInterface $credentials,
        $expires,
        array $options = []
    ) {
        if (!$request->hasHeader('x-amz-content-sha256')) {
            $request = $request->withHeader(
                'X-Amz-Content-Sha256',
                $this->getPresignedPayload($request)
            );
        }

        return parent::presign($request, $credentials, $expires, $options);
    }
496412
public static function mrr(array $options = [], ClientInterface $client = null)
    {
        return Metrics\MRRs::all($options, $client);
    }
984161
public function connectOauth2($options)
    {
        $token = false;

        // source oauth provider
        $oauthProvider = $this->getProvider();

        // error
        if(\Craft\craft()->request->getParam('error'))
        {
            throw new \Exception("An error occured: ".\Craft\craft()->request->getParam('error'));
        }

        $state = \Craft\craft()->request->getParam('state');
        $code = \Craft\craft()->request->getParam('code');
        $oauth2state = \Craft\craft()->httpSession->get('oauth2state');

        if (is_null($code))
        {
            $authorizationOptions = $options['authorizationOptions'];

            if(count($options['scope']) > 0)
            {
                $authorizationOptions['scope'] = $options['scope'];
            }

            $authorizationUrl = $oauthProvider->getAuthorizationUrl($authorizationOptions);

            $state = $oauthProvider->getState();

            \Craft\craft()->httpSession->add('oauth2state', $state);

            OauthPlugin::log('OAuth 2.0 Connect - Redirect to the authorization URL'."\r\n".
	            "authorizationUrl: ".$authorizationUrl."\r\n".
	            "oauth2state: ".\Craft\craft()->httpSession->get('oauth2state')
	        , LogLevel::Info);

            \Craft\craft()->request->redirect($authorizationUrl);
        }
        elseif (!$state || $state !== $oauth2state)
        {
            OauthPlugin::log('OAuth 2.0 Connect - Invalid State'."\r\n".print_r([
                'state' => $state,
                'oauth2state' => $oauth2state,
            ], true), LogLevel::Info);

            \Craft\craft()->httpSession->remove('oauth2state');

            throw new \Exception("Invalid state");

        }
        else
        {
            OauthPlugin::log('OAuth 2.0 Connect - Authorization code retrieved: '.$code, LogLevel::Info);

            $token = $oauthProvider->getAccessToken('authorization_code', [
                'code' => $code
            ]);

            OauthPlugin::log("OAuth 2.0 Connect - Get Access Token\r\n".
	            "Access token: \r\n".
	            print_r($token, true)
	        , LogLevel::Info);
        }

        return $token;
    }
703635
public function getAuthenticatedRequest($method, $url, $token, array $options = [])
    {
        $baseUri = new Psr7\Uri($this->urlApiDomain);
        $relativeUri = new Psr7\Uri($url);
        $newUri = Psr7\Uri::resolve($baseUri, $relativeUri);

        return parent::getAuthenticatedRequest($method, $newUri, $token, $options);
    }
447102
public function checkClientCredentials($client_id, $client_secret = null)
    {
        $sql    = sprintf('SELECT * from %s where client_id = :client_id', $this->config['client_table']);
        $result = $this->fetch($sql, compact('client_id'));

        // make this extensible
        return $result ? $result['client_secret'] == $client_secret : false;
    }
777153
public function getCredentialFields($strategy, array $options = [])
    {
        $options['httpParams'][':strategy'] = $strategy;

        return $this->kuzzle->query($this->buildQueryArgs('getCredentialFields'), [], $options)['result'];
    }
1082209
public function resetPassword($token = null, $options = []) {
		$options = Hash::merge($this->getConfig('resetPassword'), $options);

		$tokenParam = $this->_getRequest()->getQuery($options['queryParam']);
		if (!empty($tokenParam)) {
			$token = $tokenParam;
		}

		// Check of the token exists
		try {
			$entity = $this->UserTable->verifyPasswordResetToken($token, $options['tokenOptions']);
		} catch (RecordNotFoundException $e) {
			if (empty($options['errorMessage']) && $options['errorMessage'] !== false) {
				$options['errorMessage'] = $e->getMessage();
			}

			$redirect = $this->handleFlashAndRedirect('invalidError', $options);
			if ($redirect instanceof Response) {
				return $redirect;
			}
			$entity = $this->UserTable->newEntity();
		}

		// Check if the token has expired
		if ($entity->get('token_is_expired') === true) {
			if (empty($options['invalidErrorMessage'])) {
				$options['invalidErrorMessage'] = $e->getMessage();
			}
			$redirect = $this->handleFlashAndRedirect('expiredError', $options);
			if ($redirect instanceof Response) {
				return $redirect;
			}
		}

		// Handle the POST
		if ($this->_getRequest()->is('post')) {
			$entity = $this->UserTable->patchEntity($entity, $this->_getRequest()->getData());
			if ($this->UserTable->resetPassword($entity)) {
				$redirect = $this->handleFlashAndRedirect('success', $options);
			} else {
				$redirect = $this->handleFlashAndRedirect('error', $options);
			}
			if ($redirect instanceof Response) {
				return $redirect;
			}
		} else {
			$entity = $this->UserTable->newEntity();
		}

		$this->_setViewVar('entity', $entity);
	}
612069
public function checkClientCredentials($client_id, $client_secret = null)
    {
        return isset($this->clientCredentials[$client_id]['secret']) && $this->clientCredentials[$client_id]['secret'] === $client_secret;
    }
560328
public static function asp(array $options = [], ClientInterface $client = null)
    {
        return Metrics\ASPs::all($options, $client);
    }
740605
protected function getAuthorizationParameters(array $options)
    {
        if (empty($options['state'])) {
            $options['state'] = $this->getRandomState();
        }

        if (empty($options['scope'])) {
            $options['scope'] = $this->getDefaultScopes();
        }

        $options += [
            'response_type'   => 'code',
            'approval_prompt' => 'auto'
        ];

        if (is_array($options['scope'])) {
            $separator = $this->getScopeSeparator();
            $options['scope'] = implode($separator, $options['scope']);
        }

        // Store the state as it may need to be accessed later on.
        $this->state = $options['state'];

        // Business code layer might set a different redirect_uri parameter
        // depending on the context, leave it as-is
        if (!isset($options['redirect_uri'])) {
            $options['redirect_uri'] = $this->redirectUri;
        }

        $options['client_id'] = $this->clientId;

        return $options;
    }