Exemplo n.º 1
0
 def start_oauth2_dance(self):
     login_hint = ''
     scope = ''
     client = Client.get_by_id(1)
     if not client:
         # If client does not exist then create an empty one
         client = Client(id=1)
         client.installer_user = users.get_current_user().email()
         client.put()
     # Get the login hint from configuration
     approval_prompt = 'auto' if client.refresh_token else 'force'
     scope = constants.OAUTH2_SCOPE
     redirect_uri = helpers.url_for('oauth.oauth_callback',
                                    _external=True)
     oauth_helper = OAuthDanceHelper(redirect_uri, approval_prompt, scope)
     url = oauth_helper.step1_get_authorize_url()
     #TODO: Add a random token to avoid forgery
     return redirect(url)