本文整理汇总了PHP中HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\GenericOAuth2ResourceOwner类的典型用法代码示例。如果您正苦于以下问题:PHP GenericOAuth2ResourceOwner类的具体用法?PHP GenericOAuth2ResourceOwner怎么用?PHP GenericOAuth2ResourceOwner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GenericOAuth2ResourceOwner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createResourceOwner
protected function createResourceOwner(array $options, $name, $paths = null)
{
$this->buzzClient = $this->getMockBuilder('\\Buzz\\Client\\ClientInterface')->disableOriginalConstructor()->getMock();
$httpUtils = $this->getMockBuilder('\\Symfony\\Component\\Security\\Http\\HttpUtils')->disableOriginalConstructor()->getMock();
$resourceOwner = new GenericOAuth2ResourceOwner($this->buzzClient, $httpUtils, $options, $name);
$resourceOwner->addPaths($paths ?: $this->getDefaultPaths());
return $resourceOwner;
}
示例2: testCsrfTokenIsValidWhenDisabled
public function testCsrfTokenIsValidWhenDisabled()
{
if ($this->csrf) {
$this->markTestSkipped('CSRF is enabled for this Resource Owner.');
}
$this->storage->expects($this->never())->method('fetch');
$this->assertTrue($this->resourceOwner->isCsrfTokenValid('whatever you want'));
}
示例3: configureOptions
/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolverInterface $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults(array('authorization_url' => 'https://accounts.google.com/o/oauth2/auth', 'access_token_url' => 'https://accounts.google.com/o/oauth2/token', 'revoke_token_url' => 'https://accounts.google.com/o/oauth2/revoke', 'infos_url' => 'https://www.googleapis.com/oauth2/v1/userinfo', 'scope' => 'https://www.googleapis.com/auth/userinfo.profile', 'access_type' => null, 'approval_prompt' => null, 'display' => null, 'hd' => null, 'login_hint' => null, 'prompt' => null, 'request_visible_actions' => null));
if (method_exists($resolver, 'setDefined')) {
$resolver->setAllowedValues('access_type', array('online', 'offline', null))->setAllowedValues('approval_prompt', array('force', 'auto', null))->setAllowedValues('display', array('page', 'popup', 'touch', 'wap', null))->setAllowedValues('login_hint', array('email address', 'sub', null))->setAllowedValues('prompt', array('consent', 'select_account', null));
} else {
$resolver->setAllowedValues(array('access_type' => array('online', 'offline', null), 'approval_prompt' => array('force', 'auto', null), 'display' => array('page', 'popup', 'touch', 'wap', null), 'login_hint' => array('email address', 'sub', null), 'prompt' => array('consent', 'select_account', null)));
}
}
示例4: configureOptions
/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults(array('authorization_url' => '{base_url}/oauth2/authorize', 'access_token_url' => '{base_url}/oauth2/token', 'revoke_token_url' => '{base_url}/oauth2/revoke', 'infos_url' => '{base_url}/user'));
$resolver->setRequired(array('base_url'));
$normalizer = function (Options $options, $value) {
return str_replace('{base_url}', $options['base_url'], $value);
};
$resolver->setNormalizers(array('authorization_url' => $normalizer, 'access_token_url' => $normalizer, 'revoke_token_url' => $normalizer, 'infos_url' => $normalizer));
}
示例5: configureOptions
/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolverInterface $resolver)
{
parent::configureOptions($resolver);
$resolver->setRequired('base_url');
$resolver->setDefaults(array('authorization_url' => '{base_url}/admin/oauth/authorize', 'access_token_url' => '{base_url}/admin/oauth/access_token', 'infos_url' => '{base_url}/admin/shop.json', 'use_bearer_authorization' => false));
$baseUrlNormalizer = function (Options $options, $value) {
return strtr($value, ['{base_url}' => $options['base_url']]);
};
$resolver->setNormalizers(['authorization_url' => $baseUrlNormalizer, 'access_token_url' => $baseUrlNormalizer, 'infos_url' => $baseUrlNormalizer]);
}
示例6: configureOptions
/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults(array('authorization_url' => 'https://accounts.google.com/o/oauth2/auth', 'access_token_url' => 'https://accounts.google.com/o/oauth2/token', 'revoke_token_url' => 'https://accounts.google.com/o/oauth2/revoke', 'infos_url' => 'https://www.googleapis.com/youtube/v3/channels?part=id,snippet&mine=true', 'scope' => 'https://www.googleapis.com/auth/youtube.readonly', 'access_type' => null, 'approval_prompt' => null, 'display' => null, 'hd' => null, 'login_hint' => null, 'prompt' => null, 'request_visible_actions' => null));
// Symfony <2.6 BC
if (method_exists($resolver, 'setDefined')) {
$resolver->setAllowedValues('access_type', array('online', 'offline', null))->setAllowedValues('approval_prompt', array('force', 'auto', null))->setAllowedValues('display', array('page', 'popup', 'touch', 'wap', null))->setAllowedValues('login_hint', array('email address', 'sub', null))->setAllowedValues('prompt', array(null, 'consent', 'select_account', null));
} else {
$resolver->setAllowedValues(array('access_type' => array('online', 'offline', null), 'approval_prompt' => array('force', 'auto', null), 'display' => array('page', 'popup', 'touch', 'wap', null), 'login_hint' => array('email address', 'sub', null), 'prompt' => array(null, 'consent', 'select_account', null)));
}
}
示例7: configureOptions
/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolverInterface $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults(array('authorization_url' => 'https://oauth.vk.com/authorize', 'access_token_url' => 'https://oauth.vk.com/access_token', 'infos_url' => 'https://api.vk.com/method/users.get', 'use_commas_in_scope' => true, 'fields' => 'nickname,photo_50', 'name_case' => null));
$resolver->setNormalizers(array('fields' => function (Options $options, $value) {
if (!$value) {
return null;
}
return is_array($value) ? implode(',', $value) : $value;
}));
}
示例8: configureOptions
/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolverInterface $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults(array('authorization_url' => 'https://api.dailymotion.com/oauth/authorize', 'access_token_url' => 'https://api.dailymotion.com/oauth/token', 'infos_url' => 'https://api.dailymotion.com/me', 'display' => null));
if (method_exists($resolver, 'setDefined')) {
// @link http://www.dailymotion.com/doc/api/authentication.html#dialog-form-factors
$resolver->setAllowedValues('display', array('page', 'popup', 'mobile', null));
} else {
$resolver->setAllowedValues(array('display' => array('page', 'popup', 'mobile', null)));
}
}
示例9: configureOptions
/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolverInterface $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults(array('authorization_url' => 'https://www.facebook.com/v2.0/dialog/oauth', 'access_token_url' => 'https://graph.facebook.com/v2.0/oauth/access_token', 'revoke_token_url' => 'https://graph.facebook.com/v2.0/me/permissions', 'infos_url' => 'https://graph.facebook.com/v2.0/me', 'use_commas_in_scope' => true, 'display' => null, 'auth_type' => null, 'appsecret_proof' => false));
// Symfony <2.6 BC
if (method_exists($resolver, 'setDefined')) {
$resolver->setAllowedValues('display', array('page', 'popup', 'touch', null))->setAllowedValues('auth_type', array('rerequest', null))->setAllowedTypes('appsecret_proof', 'bool');
} else {
$resolver->setAllowedValues(array('display' => array('page', 'popup', 'touch', null), 'auth_type' => array('rerequest', null), 'appsecret_proof' => array(true, false)));
}
}
示例10: getUserInformation
/**
* Override for Orcid
*
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
if (!array_key_exists('orcid', $accessToken)) {
return parent::getUserInformation($accessToken, $extraParameters);
}
$orcidService = new OrcidService();
$bio = $orcidService->getBio($accessToken["orcid"]);
$response = $this->getUserResponse();
$response->setResponse($bio);
$response->setResourceOwner($this);
$response->setOAuthToken(new OAuthToken($accessToken));
return $response;
}
示例11: configureOptions
/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolverInterface $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults(array('sandbox' => false, 'scope' => 'openid email', 'authorization_url' => 'https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize', 'access_token_url' => 'https://api.paypal.com/v1/identity/openidconnect/tokenservice', 'infos_url' => 'https://api.paypal.com/v1/identity/openidconnect/userinfo/?schema=openid'));
$resolver->addAllowedTypes(array('sandbox' => 'bool'));
$sandboxTransformation = function (Options $options, $value) {
if (!$options['sandbox']) {
return $value;
}
return preg_replace('~\\.paypal\\.~', '.sandbox.paypal.', $value, 1);
};
$resolver->setNormalizers(array('authorization_url' => $sandboxTransformation, 'access_token_url' => $sandboxTransformation, 'infos_url' => $sandboxTransformation));
}
示例12: configureOptions
/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults(array('authorization_url' => '{base_url}/authorize', 'access_token_url' => '{base_url}/oauth/token', 'infos_url' => '{base_url}/userinfo'));
$resolver->setRequired(array('base_url'));
$normalizer = function (Options $options, $value) {
return str_replace('{base_url}', $options['base_url'], $value);
};
// Symfony <2.6 BC
if (method_exists($resolver, 'setNormalizer')) {
$resolver->setNormalizer('authorization_url', $normalizer)->setNormalizer('access_token_url', $normalizer)->setNormalizer('infos_url', $normalizer);
} else {
$resolver->setNormalizers(array('authorization_url' => $normalizer, 'access_token_url' => $normalizer, 'infos_url' => $normalizer));
}
}
示例13: getUserInformation
/**
* {@inheritDoc}
*/
public function getUserInformation(array $accessToken, array $extraParameters = array())
{
$response = parent::getUserInformation($accessToken, $extraParameters);
$responseData = $response->getResponse();
// fetch the email addresses linked to the account
if (empty($responseData['email'])) {
$content = $this->httpRequest($this->normalizeUrl($this->options['emails_url']), null, array('Authorization: Bearer ' . $accessToken['access_token']));
foreach ($this->getResponseContent($content)['values'] as $email) {
// we only need the primary email address
if (true === $email['is_primary']) {
$responseData['email'] = $email['email'];
}
}
$response->setResponse($responseData);
}
return $response;
}
示例14: configureOptions
/**
* {@inheritDoc}
*/
protected function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults(array('authorization_url' => 'https://oauth.vk.com/authorize', 'access_token_url' => 'https://oauth.vk.com/access_token', 'infos_url' => 'https://api.vk.com/method/users.get', 'scope' => 'email', 'use_commas_in_scope' => true, 'fields' => 'nickname,photo_medium,screen_name,email', 'name_case' => null));
$fieldsNormalizer = function (Options $options, $value) {
if (!$value) {
return null;
}
return is_array($value) ? implode(',', $value) : $value;
};
// Symfony <2.6 BC
if (method_exists($resolver, 'setNormalizer')) {
$resolver->setNormalizer('fields', $fieldsNormalizer);
} else {
$resolver->setNormalizers(array('fields' => $fieldsNormalizer));
}
}
示例15: getResponseContent
/**
* {@inheritDoc}
*/
protected function getResponseContent(HttpMessageInterface $rawResponse)
{
$response = parent::getResponseContent($rawResponse);
// Foursquare use quite custom response structure in case of error
if (isset($response['meta']['errorType'])) {
// Prevent to mark deprecated calls as errors
if (200 == $response['meta']['code']) {
$response['error'] = $response['meta']['errorType'];
// Try to add some details of error if available
if (isset($response['meta']['errorMessage'])) {
$response['error'] .= ' ' . $response['meta']['errorMessage'];
} elseif (isset($response['meta']['errorDetail'])) {
$response['error'] .= ' ' . $response['meta']['errorDetail'];
}
}
unset($response['meta']);
}
return $response;
}