From 373596cd1b63b041069779de2dbddb295aec0c2b Mon Sep 17 00:00:00 2001 From: Luc Perkins <luc@Lucs-MacBook-Pro.local> Date: Fri, 7 Jun 2013 15:28:06 -0700 Subject: [PATCH 1/4] updated python sample code to use the Requests module instead of urllib and urllib2 --- python/rpxtokenurl.py | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/python/rpxtokenurl.py b/python/rpxtokenurl.py index 3ed9f63..e7ec68d 100644 --- a/python/rpxtokenurl.py +++ b/python/rpxtokenurl.py @@ -1,10 +1,6 @@ # This code sample shows how to make the auth_info API call using Python. -import urllib -import urllib2 - -# json is native in python 2.6, but must be installed for previous versions -import json +import requests # Step 1) Extract the token from your environment. If you are using app engine, # you'd do something like: @@ -24,23 +20,24 @@ # Step 2) Now that we have the token, we need to make the api call to auth_info. # auth_info expects an HTTP Post with the following paramters: -api_params = { +engage_api_params = { 'token': token, 'apiKey': 'REPLACE_WITH_YOUR_RPX_API_KEY', - 'format': 'json', + 'format': 'json' } +engage_api_url = 'https://rpxnow.com/api/v2/auth_info' + # make the api call -http_response = urllib2.urlopen('https://rpxnow.com/api/v2/auth_info', - urllib.urlencode(api_params)) -# read the json response -auth_info_json = http_response.read() +api_response = requests.get(engage_api_url, params=engage_api_params) # Step 3) process the json response -auth_info = json.loads(auth_info_json) + +auth_info = api_response.json() # Step 4) use the response to sign the user in + if auth_info['stat'] == 'ok': profile = auth_info['profile'] From 8c20b054305f602d0dc923502148d10eed01a287 Mon Sep 17 00:00:00 2001 From: Luc Perkins <luc@Lucs-MacBook-Pro.local> Date: Fri, 7 Jun 2013 15:29:16 -0700 Subject: [PATCH 2/4] small fix --- python/rpxtokenurl.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/python/rpxtokenurl.py b/python/rpxtokenurl.py index e7ec68d..cfcd09b 100644 --- a/python/rpxtokenurl.py +++ b/python/rpxtokenurl.py @@ -57,7 +57,4 @@ sign_in_user(identifier, name, email, profile_pic_url) else: - print 'An error occured: ' + auth_info['err']['msg'] - - - + print 'An error occured: ' + auth_info['err']['msg'] \ No newline at end of file From 0407d66d274333e70e9f8b7c8dd04f283365731a Mon Sep 17 00:00:00 2001 From: Luc Perkins <luc@Lucs-MacBook-Pro.local> Date: Fri, 7 Jun 2013 15:30:08 -0700 Subject: [PATCH 3/4] updated Python sample code to use the Requests module instead of urllib and urllib2 --- python/rpxtokenurl.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/rpxtokenurl.py b/python/rpxtokenurl.py index cfcd09b..f63d835 100644 --- a/python/rpxtokenurl.py +++ b/python/rpxtokenurl.py @@ -20,6 +20,7 @@ # Step 2) Now that we have the token, we need to make the api call to auth_info. # auth_info expects an HTTP Post with the following paramters: + engage_api_params = { 'token': token, 'apiKey': 'REPLACE_WITH_YOUR_RPX_API_KEY', From 1ae9298344e32069dc0e9671cbf022bd1b5eecf5 Mon Sep 17 00:00:00 2001 From: Luc Perkins <lucperkins@gmail.com> Date: Fri, 8 Nov 2013 14:49:01 -0800 Subject: [PATCH 4/4] change 'text/javascript' to 'application/json' in Java servlet example --- .../src/main/java/com/janrain/example/AuthInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/standalone-servlet-example/src/main/java/com/janrain/example/AuthInfo.java b/java/standalone-servlet-example/src/main/java/com/janrain/example/AuthInfo.java index b013dc8..ff2ccd7 100644 --- a/java/standalone-servlet-example/src/main/java/com/janrain/example/AuthInfo.java +++ b/java/standalone-servlet-example/src/main/java/com/janrain/example/AuthInfo.java @@ -41,7 +41,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response) thr writer.close(); // Here, we're just copying the response returned by the API to the page served to the browser. response.setCharacterEncoding("UTF-8"); - response.setContentType("text/javascript"); + response.setContentType("application/json"); IOUtils.copy(connection.getInputStream(), response.getOutputStream()); }