diff --git a/README.md b/README.md index 3b10116..145bc1f 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ Connections that Authlib Loginpass contains: - [x] Yandex - [x] Twitch - [x] VK +- [x] Mail.ru - [x] [Ory Hydra](https://www.ory.sh/docs/hydra/) Usage diff --git a/loginpass/__init__.py b/loginpass/__init__.py index e8f63a7..649086d 100644 --- a/loginpass/__init__.py +++ b/loginpass/__init__.py @@ -24,6 +24,7 @@ from .vk import VK from .orcid import ORCiD from .hydra import create_hydra_backend +from .mailru import MailRu __all__ = [ @@ -52,6 +53,7 @@ 'VK', 'ORCiD', 'create_hydra_backend', + 'MailRu', ] __version__ = version diff --git a/loginpass/mailru.py b/loginpass/mailru.py new file mode 100644 index 0000000..7e12dfa --- /dev/null +++ b/loginpass/mailru.py @@ -0,0 +1,38 @@ +from ._core import map_profile_fields + +def normalize_userinfo(client, data): + return map_profile_fields(data, + { + 'sub': 'id', + 'email' : 'email', + 'name': 'nickname', + 'given_name': 'first_name', + 'family_name': 'last_name', + 'preferred_username': 'name', + 'picture': "image", + 'gender': 'gender', + 'birthdate': 'birthday' + }) + + + +class MailRu(object): + NAME = 'mailru' + OAUTH_CONFIG = { + 'api_base_url': 'https://oauth.mail.ru/', + 'access_token_url': 'https://oauth.mail.ru/token', + 'authorize_url': 'https://oauth.mail.ru/login', + 'userinfo_endpoint': 'https://oauth.mail.ru/userinfo', + 'userinfo_compliance_fix': normalize_userinfo, + 'authorize_params ': + { + 'scope': 'userinfo' + }, + 'request_token_params': + { + 'scope': 'userinfo' + }, + 'client_kwargs': {'scope': 'userinfo', 'token_placement': 'uri',} + } + + diff --git a/loginpass/vk.py b/loginpass/vk.py index 2a5ae12..4490470 100644 --- a/loginpass/vk.py +++ b/loginpass/vk.py @@ -19,7 +19,7 @@ USERINFO_ENDPOINT = ( 'users.get?fields=sex,bdate,has_photo,photo_max_orig,site,screen_name' - '&v=5.80' + '&v=5.131' )