Login

Django plugin for LoginRadius

Author:
diegolis
Posted:
February 10, 2012
Language:
Python
Version:
1.3
Tags:
login oauth social LoginRadius
Score:
0 (after 0 ratings)

Dependencies: urllib, simplejson

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import urllib
import simplejson

class LoginRadius:
    def __init__(self, request, api_secrete):
        self.is_authenticated = False
        if "token" in request.POST:
            validate_url = "http://hub.loginradius.com/userprofile.ashx?token=%s&apisecrete=%s" % (request.POST['token'], api_secrete)
            response = urllib.urlopen(validate_url)
            json_response = response.read()
            if json_response:
                self.user_profile=simplejson.loads(json_response)
                if "ID" in self.user_profile and self.user_profile["ID"]:
                    self.is_authenticated = True


"""
Example view:

from login import LoginRadius

def login_with_loginradius(request):
    login = LoginRadius(request, SECRET_KEY)
    if login.is_authenticated:
        profile = login.user_profile
        # profile is a dict with all the information retrieved by the provider
        ...
"""

More like this

Comments

Please login first before commenting.