The start of something beautiful

This commit is contained in:
2024-09-11 22:48:07 -06:00
parent 45acea47f3
commit f5997ee5ec
5614 changed files with 630696 additions and 0 deletions
@@ -0,0 +1,55 @@
<?php
/*
* This file is part of the HWIOAuthBundle package.
*
* (c) Hardware Info <opensource@hardware.info>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace HWI\Bundle\OAuthBundle\OAuth\ResourceOwner;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @author Anton Kamenschikov <wiistriker [at] gmail.com>
*/
final class YandexResourceOwner extends GenericOAuth2ResourceOwner
{
public const TYPE = 'yandex';
/**
* {@inheritdoc}
*/
protected array $paths = [
'identifier' => 'id',
'nickname' => 'display_name',
'realname' => 'real_name',
'email' => 'default_email',
];
/**
* {@inheritdoc}
*/
protected function doGetUserInformationRequest($url, array $parameters = [])
{
// Yandex require to pass the OAuth token as 'oauth_token' instead of 'access_token'
return $this->httpRequest(str_replace('access_token', 'oauth_token', $url));
}
/**
* {@inheritdoc}
*/
protected function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults([
'authorization_url' => 'https://oauth.yandex.ru/authorize',
'access_token_url' => 'https://oauth.yandex.ru/token',
'infos_url' => 'https://login.yandex.ru/info?format=json',
]);
}
}