Login

Django plugin for LoginRadius

Author:
diegolis
Posted:
February 10, 2012
Language:
Python
Version:
1.3
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

  1. "Magic Link" Management Command by webology 4 months, 1 week ago
  2. Closest ORM models to a latitude/longitude point by simonw 4 months, 1 week ago
  3. Log the time taken to execute each DB query by kennyx46 4 months, 1 week ago
  4. django database snippet by ItsRLuo 4 months, 2 weeks ago
  5. Serialize a model instance by chriswedgwood 5 months, 2 weeks ago

Comments

Please login first before commenting.