Created
October 24, 2013 04:04
-
-
Save chriskief/7131179 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
from django.conf import settings | |
from django.core.urlresolvers import reverse | |
from django.core.context_processors import csrf | |
def get_authorization_url(request): | |
# encode the url | |
redirect_url = urllib.quote_plus(settings.SITE_URL + reverse('register_microsoft')) | |
# create a unique state value for CSRF validation | |
request.session['microsoft_state'] = unicode(csrf(request)['csrf_token']) | |
# redirect to microsoft for approval | |
url = 'https://login.live.com/oauth20_authorize.srf?' \ | |
+ 'client_id=' + settings.MICROSOFT_CLIENT_ID \ | |
+ '&redirect_uri=' + redirect_url \ | |
+ '&scope=wl.signin%20wl.basic%20wl.emails' \ | |
+ '&state=' + request.session['microsoft_state'] \ | |
+ '&response_type=code' | |
return url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment