[Python-modules-commits] [python-social-auth] 17/322: PEP8 + basic docs. Refs #412

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Dec 24 15:12:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to tag v0.2.10
in repository python-social-auth.

commit 4fbb525a5564691a7b2bfa49ffa585f6f21f5d97
Author: Matías Aguirre <matiasaguirre at gmail.com>
Date:   Sat Nov 1 22:50:44 2014 -0200

    PEP8 + basic docs. Refs #412
---
 docs/backends/index.rst       |  1 +
 docs/backends/salesforce.rst  | 44 +++++++++++++++++++++++++++++++++++++++++++
 social/backends/salesforce.py |  9 ++++-----
 3 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/docs/backends/index.rst b/docs/backends/index.rst
index 74b5b5d..e7d4c41 100644
--- a/docs/backends/index.rst
+++ b/docs/backends/index.rst
@@ -96,6 +96,7 @@ Social backends
    readability
    reddit
    runkeeper
+   salesforce
    shopify
    skyrock
    soundcloud
diff --git a/docs/backends/salesforce.rst b/docs/backends/salesforce.rst
new file mode 100644
index 0000000..9b440a3
--- /dev/null
+++ b/docs/backends/salesforce.rst
@@ -0,0 +1,44 @@
+Salesforce
+==========
+
+Salesforce uses OAuth v2 for Authentication, check the `official docs`_.
+
+- Create an app following the steps in the `Defining Connected Apps`_ docs.
+
+- Fill ``Client Id`` and ``Client Secret`` values in the settings::
+
+        SOCIAL_AUTH_SALESFORCE_OAUTH2_KEY = '<App UID>'
+        SOCIAL_AUTH_SALESFORCE_OAUTH2_SECRET = '<App secret>'
+
+- Add the backend to the ``AUTHENTICATION_BACKENDS`` setting::
+
+        AUTHENTICATION_BACKENDS = (
+            ...
+            'social.backends.salesforce.SalesforceOAuth2',
+            ...
+        )
+
+- Then you can start using ``{% url social:begin 'salesforce-oauth2' %}`` in
+  your templates
+
+
+If using the sandbox mode:
+
+- Fill these settings instead::
+
+        SOCIAL_AUTH_SALESFORCE_OAUTH2_SANDBOX_KEY = '<App UID>'
+        SOCIAL_AUTH_SALESFORCE_OAUTH2_SANDBOX_SECRET = '<App secret>'
+
+- And this backend::
+
+        AUTHENTICATION_BACKENDS = (
+            ...
+            'social.backends.salesforce.SalesforceOAuth2Sandbox',
+            ...
+        )
+
+- Then you can start using ``{% url social:begin 'salesforce-oauth2-sandbox' %}``
+  in your templates
+
+.. _official docs: https://www.salesforce.com/us/developer/docs/api_rest/Content/intro_understanding_web_server_oauth_flow.htm
+.. _Defining Connected Apps: https://www.salesforce.com/us/developer/docs/api_rest/Content/intro_defining_remote_access_applications.htm
diff --git a/social/backends/salesforce.py b/social/backends/salesforce.py
index 5ca77e2..ccaca63 100644
--- a/social/backends/salesforce.py
+++ b/social/backends/salesforce.py
@@ -5,7 +5,8 @@ from social.backends.oauth import BaseOAuth2
 class SalesforceOAuth2(BaseOAuth2):
     """Salesforce OAuth2 authentication backend"""
     name = 'salesforce-oauth2'
-    AUTHORIZATION_URL = 'https://login.salesforce.com/services/oauth2/authorize'
+    AUTHORIZATION_URL = \
+        'https://login.salesforce.com/services/oauth2/authorize'
     ACCESS_TOKEN_URL = 'https://login.salesforce.com/services/oauth2/token'
     REVOKE_TOKEN_URL = 'https://login.salesforce.com/services/oauth2/revoke'
     ACCESS_TOKEN_METHOD = 'POST'
@@ -17,7 +18,7 @@ class SalesforceOAuth2(BaseOAuth2):
         ('issued_at', 'issued_at'),
         ('signature', 'signature'),
         ('refresh_token', 'refresh_token'),
-        ]
+    ]
 
     def get_user_details(self, response):
         """Return user details from a Salesforce account"""
@@ -32,9 +33,7 @@ class SalesforceOAuth2(BaseOAuth2):
     def user_data(self, access_token, *args, **kwargs):
         """Loads user data from service"""
         user_id_url = kwargs.get('response').get('id')
-        url = user_id_url + '?' + urlencode({
-            'access_token': access_token
-        })
+        url = user_id_url + '?' + urlencode({'access_token': access_token})
         try:
             return self.get_json(url)
         except ValueError:

-- 
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