Django plugin for LoginRadius

 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. Use django-social-auth & Google Accounts for admin login by pmdarrow 6 months, 2 weeks ago
  2. Twitter oAuth example by henriklied 4 years, 3 months ago
  3. Registering Facebook user by username before loggin in by zjor 1 week ago
  4. URL redirects middleware by gonz 5 years, 6 months ago
  5. TwitterBackend by hameedullah 4 years, 1 month ago

Comments

(Forgotten your password?)