Answer the question
In order to leave comments, you need to log in
Ulogin: what causes 'invalid token' error?
The code of the Ulogin panel itself without changes was taken from the constructor and embedded into the page without changes:
<script src="//ulogin.ru/js/ulogin.js"></script>
<div id="uLogin"
data-ulogin="display=panel;fields=first_name,last_name;providers=vkontakte,facebook,twitter,livejournal,google,openid;hidden=other;redirect_uri=http%3A%2F%2F127.0.0.1%3A5000%2Fauth%2Fsocauth"></div>
if request.method == 'POST':
server = request.environ['HTTP_HOST']
token = request.form['token']
ulmanager = ulogin.UloginManager(token,server)
self.token=token
self.server = server
url = 'http://ulogin.ru/token.php'
data = urllib.urlencode({'token': self.token, 'host': self.server})
self.ulogin = urllib2.Request(url,data)
self.ulogin = urllib2.urlopen(self.ulogin)
self.ulogin = self.ulogin.read()
$s = file_get_contents('http://ulogin.ru/token.php?token=' . $_POST['token'] . '&host=' . $_SERVER['HTTP_HOST']);
$user = json_decode($s, true);
//$user['network'] - соц. сеть, через которую авторизовался пользователь
//$user['identity'] - уникальная строка определяющая конкретного пользователя соц. сети
//$user['first_name'] - имя пользователя
//$user['last_name'] - фамилия пользователя
Answer the question
In order to leave comments, you need to log in
The source of the problem was that the value of the token and the server must be passed as the GET method, and in the meantime self.ulogin = urllib2.Request(url,data) assumes that a POST request will be generated, and therefore the data stored in the date variable must be added to the url manually , like so:
data = urllib.urlencode({'token': self.token, 'host': self.server})
ulogin = urllib2.urlopen(url+'?'+data)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question