From: Stas Kravets Date: Thu, 19 Jan 2012 09:29:58 +0000 (+0400) Subject: Yandex OAuth2: Token moved to Authorization header X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=1ec6fd0ef7804139c334796e297271d3b7a224dd;p=django-social-auth.git Yandex OAuth2: Token moved to Authorization header --- diff --git a/social_auth/backends/contrib/yandex.py b/social_auth/backends/contrib/yandex.py index 8030e5b..cf881aa 100644 --- a/social_auth/backends/contrib/yandex.py +++ b/social_auth/backends/contrib/yandex.py @@ -104,8 +104,8 @@ class YandexOAuth2(BaseOAuth2): def user_data(self, access_token): """Return user data from Yandex REST API specified in settings""" - params = urlencode({'oauth_token': access_token, 'text': 1, 'format': 'xml'}) - request = Request(settings.YANDEX_OAUTH2_API_URL + '?' + params) + params = urlencode({'text': 1, 'format': 'xml'}) + request = Request(settings.YANDEX_OAUTH2_API_URL + '?' + params, headers={'Authorization': "OAuth " + access_token }) try: dom = xml.dom.minidom.parseString(urlopen(request).read()) @@ -132,6 +132,7 @@ def getNodeText(dom, nodeName): for node in nodelist: if node.nodeType == node.TEXT_NODE: rc.append(node.data) + return ''.join(rc) def getNodesWithAttribute(dom, nodeName, attrDict): @@ -140,7 +141,9 @@ def getNodesWithAttribute(dom, nodeName, attrDict): for node in nodelist: for key, value in attrDict.items(): - if node.hasAttribute(key) and node.getAttribute(key) == value: + if node.hasAttribute(key): + if value and node.getAttribute(key) != value: + continue found.append(node) return found