[Python-modules-commits] [python-social-auth] 16/89: added support for ArcGIS OAuth2
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:15:28 UTC 2016
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to tag v0.2.15
in repository python-social-auth.
commit 674e4f193b0084d3f926cae0aac27e06b7750bf2
Author: Alain St. Pierre <alain at aspcanada.com>
Date: Thu Jan 14 16:55:47 2016 -0800
added support for ArcGIS OAuth2
---
docs/backends/arcgis.rst | 26 ++++++++++++++++++++++++++
docs/thanks.rst | 2 ++
social/backends/arcgis.py | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+)
diff --git a/docs/backends/arcgis.rst b/docs/backends/arcgis.rst
new file mode 100644
index 0000000..6c402cd
--- /dev/null
+++ b/docs/backends/arcgis.rst
@@ -0,0 +1,26 @@
+ArcGIS
+=====
+
+ArcGIS uses OAuth2 for authentication.
+
+- Register a new application at `ArcGIS Developer Center`_.
+
+
+OAuth2
+------------
+
+1. Add the OAuth2 backend to your settings page::
+
+ AUTHENTICATION_BACKENDS = (
+ ...
+ 'social.backends.arcgis.ArcGISOAuth2',
+ ...
+ )
+
+2. Fill ``Client Id`` and ``Client Secret`` values in the settings::
+
+ SOCIAL_AUTH_ARCGIS_KEY = ''
+ SOCIAL_AUTH_ARCGIS_SECRET = ''
+
+
+.. _ArcGIS Developer Center: https://developers.arcgis.com/
diff --git a/docs/thanks.rst b/docs/thanks.rst
index 8dd42c9..ca4a40e 100644
--- a/docs/thanks.rst
+++ b/docs/thanks.rst
@@ -109,6 +109,7 @@ let me know and I'll update the list):
* bluszcz_
* vbsteven_
* sbassi_
+ * aspcanada_
.. _python-social-auth: https://github.com/omab/python-social-auth
@@ -213,3 +214,4 @@ let me know and I'll update the list):
.. _bluszcz: https://github.com/bluszcz
.. _vbsteven: https://github.com/vbsteven
.. _sbassi: https://github.com/sbassi
+.. _aspcanada: https://github.com/aspcanada
diff --git a/social/backends/arcgis.py b/social/backends/arcgis.py
new file mode 100644
index 0000000..7f54b3c
--- /dev/null
+++ b/social/backends/arcgis.py
@@ -0,0 +1,35 @@
+"""
+ArcGIS OAuth2 backend
+"""
+from social.backends.oauth import BaseOAuth2
+
+
+class ArcGISOAuth2(BaseOAuth2):
+ name = 'arcgis'
+ ID_KEY = 'username'
+ AUTHORIZATION_URL = 'https://www.arcgis.com/sharing/rest/oauth2/authorize'
+ ACCESS_TOKEN_URL = 'https://www.arcgis.com/sharing/rest/oauth2/token'
+ ACCESS_TOKEN_METHOD = 'POST'
+ EXTRA_DATA = [
+ ('expires_in', 'expires_in')
+ ]
+
+ def get_user_details(self, response):
+ """Return user details from ArcGIS account"""
+ return {'username': response.get('username'),
+ 'email': response.get('email'),
+ 'fullname': response.get('fullName'),
+ 'first_name': response.get('firstName'),
+ 'last_name': response.get('lastName')}
+
+ def user_data(self, access_token, *args, **kwargs):
+ """Loads user data from service"""
+ data = self.get_json(
+ 'https://www.arcgis.com/sharing/rest/community/self',
+ params={
+ 'token': access_token,
+ 'f': 'json'
+ }
+ )
+
+ return data
--
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