def oauth2_authorize(request):
 return_url = request.GET.get('return_url', None)
 if (not return_url):
  return_url = request.META.get('HTTP_REFERER', '/')
 scopes = request.GET.getlist('scopes', django_util.oauth2_settings.scopes)
 if django_util.oauth2_settings.storage_model:
  if (not request.user.is_authenticated()):
   return redirect('{0}?next={1}'.format(settings.LOGIN_URL, parse.quote(request.get_full_path())))
  else:
   user_oauth = django_util.UserOAuth2(request, scopes, return_url)
   if user_oauth.has_credentials():
    return redirect(return_url)
 flow = _make_flow(request=request, scopes=scopes, return_url=return_url)
 auth_url = flow.step1_get_authorize_url()
 return shortcuts.redirect(auth_url)

def oauth2_authorize ( request ) : return_url = request . GET . get ( 'return_url' , None ) if ( not return_url ) : return_url = request . META . get ( 'HTTP_REFERER' , '/' ) scopes = request . GET . getlist ( 'scopes' , django_util . oauth2_settings . scopes ) if django_util . oauth2_settings . storage_model : if ( not request . user . is_authenticated ( ) ) : return redirect ( '{0}?next={1}' . format ( settings . LOGIN_URL , parse . quote ( request . get_full_path ( ) ) ) ) else : user_oauth = django_util . UserOAuth2 ( request , scopes , return_url ) if user_oauth . has_credentials ( ) : return redirect ( return_url ) flow = _make_flow ( request = request , scopes = scopes , return_url = return_url ) auth_url = flow . step1_get_authorize_url ( ) return shortcuts . redirect ( auth_url )
view to start the oauth2 authorization flow .