/** * {@inheritdoc} */ public function createAuthCode(ClientInterface $client, EndUserInterface $end_user, array $query_params, $redirectUri, array $scope = [], $issueRefreshToken = false) { $length = $this->getAuthCodeLength(); $charset = $this->getConfiguration()->get('auth_code_charset', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~+/'); try { $code = DefuseGenerator::getRandomString($length, $charset); } catch (\Exception $e) { throw $this->createException($e->getMessage()); } if (!is_string($code) || strlen($code) !== $length) { throw $this->createException('An error has occurred during the creation of the authorization code.'); } $authcode = $this->addAuthCode($code, time() + $this->getLifetime($client), $client, $end_user, $query_params, $redirectUri, $scope, $issueRefreshToken); return $authcode; }
/** * {@inheritdoc} */ public function createRefreshToken(ClientInterface $client, ResourceOwnerInterface $resourceOwner, array $scope = []) { $length = $this->getRefreshTokenLength(); $charset = $this->getConfiguration()->get('refresh_token_charset', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~+/'); try { $token = DefuseGenerator::getRandomString($length, $charset); } catch (\Exception $e) { throw $this->createException($e->getMessage()); } if (!is_string($token) || strlen($token) !== $length) { throw $this->createException('An error has occurred during the creation of the refresh token.'); } $refresh_token = $this->addRefreshToken($token, time() + $this->getLifetime($client), $client, $resourceOwner, $scope); return $refresh_token; }