[Python-modules-commits] [python-social-auth] 13/61: Add orbi backend
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:14:02 UTC 2016
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to tag v0.2.13
in repository python-social-auth.
commit ef70edb0cbb8c38892be70e44482a49b62e9c958
Author: Lee Jaeyoung <jaeyoung at monodiary.net>
Date: Thu Jul 16 11:46:48 2015 +0900
Add orbi backend
---
docs/backends/orbi.rst | 17 +++++++++++++++++
social/backends/orbi.py | 39 ++++++++++++++++++++++++++++++++++++++
social/tests/backends/test_orbi.py | 30 +++++++++++++++++++++++++++++
3 files changed, 86 insertions(+)
diff --git a/docs/backends/orbi.rst b/docs/backends/orbi.rst
new file mode 100644
index 0000000..0cc0a79
--- /dev/null
+++ b/docs/backends/orbi.rst
@@ -0,0 +1,17 @@
+Orbi
+====
+
+Orbi OAuth v2 for Authentication.
+
+- Register a new applicationat the `Orbi API`_, and
+
+- Fill ``Client Id`` and ``Client Secret`` values in the settings::
+
+ SOCIAL_AUTH_ORBI_KEY = ''
+ SOCIAL_AUTH_ORBI_SECRET = ''
+
+- Also it's possible to define extra permissions with::
+
+ SOCIAL_AUTH_KAKAO_SCOPE = ['all']
+
+.. _Orbi API: http://orbi.kr
diff --git a/social/backends/orbi.py b/social/backends/orbi.py
new file mode 100644
index 0000000..177d6fe
--- /dev/null
+++ b/social/backends/orbi.py
@@ -0,0 +1,39 @@
+"""
+Orbi OAuth2 backend
+"""
+from social.backends.oauth import BaseOAuth2
+
+
+class OrbiOAuth2(BaseOAuth2):
+ """Orbi OAuth2 authentication backend"""
+ name = 'orbi'
+ AUTHORIZATION_URL = 'https://login.orbi.kr/oauth/authorize'
+ ACCESS_TOKEN_URL = 'https://login.orbi.kr/oauth/token'
+ ACCESS_TOKEN_METHOD = 'POST'
+ EXTRA_DATA = [
+ ('imin', 'imin'),
+ ('nick', 'nick'),
+ ('photo', 'photo'),
+ ('sex', 'sex'),
+ ('birth', 'birth'),
+ ]
+
+ def get_user_id(self, details, response):
+ return response
+
+ def get_user_details(self, response):
+ fullname, first_name, last_name = self.get_user_names(response.get('name', ''),
+ response.get('first_name', ''),
+ response.get('last_name', ''))
+
+ return {
+ 'username': response.get('username', response.get('name')),
+ 'email': response.get('email', ''),
+ 'fullname': fullname,
+ 'first_name': first_name,
+ 'last_name': last_name,
+ }
+
+ def user_data(self, access_token, *args, **kwargs):
+ """Load user data from orbi"""
+ return self.get_json('https://login.orbi.kr/oauth/user/get', params={'access_token': access_token})
diff --git a/social/tests/backends/test_orbi.py b/social/tests/backends/test_orbi.py
new file mode 100644
index 0000000..a35a1d5
--- /dev/null
+++ b/social/tests/backends/test_orbi.py
@@ -0,0 +1,30 @@
+import json
+
+from social.tests.backends.oauth import OAuth2Test
+
+
+class OrbiOAuth2Test(OAuth2Test):
+ backend_path = 'social.backends.orbi.OrbiOAuth2'
+ user_data_url = 'https://login.orbi.kr/oauth/user/get'
+ access_token_body = json.dumps({
+ 'access_token': 'foobar',
+ })
+ user_data_body = json.dumps({
+ 'username': 'foobar',
+ 'first_name': 'Foo',
+ 'last_name': 'Bar',
+ 'name': 'Foo Bar',
+
+ 'imin': '100000',
+ 'nick': 'foobar',
+ 'photo': 'http://s3.orbi.kr/data/member/wi/wizetdev_132894975780.jpeg',
+ 'sex': 'M',
+ 'birth': '1973-08-03'
+
+ })
+
+ def test_login(self):
+ self.do_login()
+
+ def test_partial_pipeline(self):
+ self.do_partial_pipeline()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-social-auth.git
More information about the Python-modules-commits
mailing list