Python oauth2client.client.OAuth2WebServerFlow() Examples
The following are 30
code examples of oauth2client.client.OAuth2WebServerFlow().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
oauth2client.client
, or try the search function
.
Example #1
Source File: appengine.py From data with GNU General Public License v3.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow(self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #2
Source File: gDrive.py From X-tra-Telegram with Apache License 2.0 | 6 votes |
def create_token_file(token_file, event): # Run through the OAuth flow and retrieve credentials flow = OAuth2WebServerFlow( CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, redirect_uri=REDIRECT_URI ) authorize_url = flow.step1_get_authorize_url() async with bot.conversation(int(Var.PRIVATE_GROUP_ID)) as conv: await conv.send_message(f"Go to the following link in your browser: {authorize_url} and reply the code") response = conv.wait_event(events.NewMessage( outgoing=True, chats=int(Var.PRIVATE_GROUP_ID) )) response = await response code = response.message.message.strip() credentials = flow.step2_exchange(code) storage = Storage(token_file) storage.put(credentials) return storage
Example #3
Source File: appengine.py From luci-py with Apache License 2.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow( self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #4
Source File: appengine.py From luci-py with Apache License 2.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow( self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #5
Source File: appengine.py From luci-py with Apache License 2.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow( self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #6
Source File: appengine.py From luci-py with Apache License 2.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow( self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #7
Source File: appengine.py From jarvis with GNU General Public License v2.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = client.OAuth2WebServerFlow( self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #8
Source File: appengine.py From luci-py with Apache License 2.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow( self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #9
Source File: glink.py From BotHub with Apache License 2.0 | 6 votes |
def create_token_file(token_file, event): # Run through the OAuth flow and retrieve credentials flow = OAuth2WebServerFlow( CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, redirect_uri=REDIRECT_URI ) authorize_url = flow.step1_get_authorize_url() async with event.client.conversation(Config.PRIVATE_GROUP_BOT_API_ID) as conv: await conv.send_message(f"Go to the following link in your browser: {authorize_url} and reply the code") response = conv.wait_event(events.NewMessage( outgoing=True, chats=Config.PRIVATE_GROUP_BOT_API_ID )) response = await response code = response.message.message.strip() credentials = flow.step2_exchange(code) storage = Storage(token_file) storage.put(credentials) return storage
Example #10
Source File: appengine.py From twitter-for-bigquery with Apache License 2.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow(self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #11
Source File: appengine.py From data with GNU General Public License v3.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow( self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #12
Source File: appengine.py From alfred-gmail with MIT License | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = client.OAuth2WebServerFlow( self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #13
Source File: cleaner.py From google-drive-trash-cleaner with GNU General Public License v3.0 | 6 votes |
def get_credentials(flags): """Gets valid user credentials from storage. If nothing has been stored, or if the stored credentials are invalid, the OAuth2 flow is completed to obtain the new credentials. Returns: Credentials, the obtained credential. """ store = Storage(flags.credfile) with warnings.catch_warnings(): warnings.simplefilter("ignore") credentials = store.get() if not credentials or credentials.invalid: flow = client.OAuth2WebServerFlow(**CLIENT_CREDENTIAL) credentials = tools.run_flow(flow, store, flags) print('credential file saved at\n\t' + flags.credfile) return credentials
Example #14
Source File: gdrivenew.py From BotHub with Apache License 2.0 | 6 votes |
def create_token_file(token_file, event): # Run through the OAuth flow and retrieve credentials flow = OAuth2WebServerFlow( CLIENT_ID, CLIENT_SECRET, OAUTH_SCOPE, redirect_uri=REDIRECT_URI ) authorize_url = flow.step1_get_authorize_url() async with event.client.conversation(Config.PRIVATE_GROUP_BOT_API_ID) as conv: await conv.send_message(f"Go to the following link in your browser: {authorize_url} and reply the code") response = conv.wait_event(events.NewMessage( outgoing=True, chats=Config.PRIVATE_GROUP_BOT_API_ID )) response = await response code = response.message.message.strip() credentials = flow.step2_exchange(code) storage = Storage(token_file) storage.put(credentials) return storage
Example #15
Source File: appengine.py From googleapps-message-recall with Apache License 2.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow(self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #16
Source File: auth.py From freight with Apache License 2.0 | 6 votes |
def get_auth_flow(redirect_uri=None): # XXX(dcramer): we have to generate this each request because oauth2client # doesn't want you to set redirect_uri as part of the request, which causes # a lot of runtime issues. auth_uri = GOOGLE_AUTH_URI if current_app.config["GOOGLE_DOMAIN"]: auth_uri = auth_uri + "?hd=" + current_app.config["GOOGLE_DOMAIN"] return OAuth2WebServerFlow( client_id=current_app.config["GOOGLE_CLIENT_ID"], client_secret=current_app.config["GOOGLE_CLIENT_SECRET"], scope="https://www.googleapis.com/auth/userinfo.email", redirect_uri=redirect_uri, user_agent=f"freight/{freight.VERSION} (python {PYTHON_VERSION})", auth_uri=auth_uri, token_uri=GOOGLE_TOKEN_URI, revoke_uri=GOOGLE_REVOKE_URI, )
Example #17
Source File: appengine.py From data with GNU General Public License v3.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow(self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #18
Source File: appengine.py From data with GNU General Public License v3.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow( self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #19
Source File: appengine.py From aqua-monitor with GNU Lesser General Public License v3.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow( self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #20
Source File: views.py From aqua-monitor with GNU Lesser General Public License v3.0 | 6 votes |
def _make_flow(request, scopes, return_url=None): """Creates a Web Server Flow""" # Generate a CSRF token to prevent malicious requests. csrf_token = hashlib.sha256(os.urandom(1024)).hexdigest() request.session[_CSRF_KEY] = csrf_token state = json.dumps({ 'csrf_token': csrf_token, 'return_url': return_url, }) flow = client.OAuth2WebServerFlow( client_id=django_util.oauth2_settings.client_id, client_secret=django_util.oauth2_settings.client_secret, scope=scopes, state=state, redirect_uri=request.build_absolute_uri( urlresolvers.reverse("google_oauth:callback"))) flow_key = _FLOW_KEY.format(csrf_token) request.session[flow_key] = pickle.dumps(flow) return flow
Example #21
Source File: appengine.py From billing-export-python with Apache License 2.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow(self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #22
Source File: appengine.py From sndlatr with Apache License 2.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow(self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #23
Source File: configure_oauth.py From splunk-ref-pas-code with Apache License 2.0 | 6 votes |
def handle_POST(self): redirect_uri = 'urn:ietf:wg:oauth:2.0:oob' oauth_scope = 'https://www.googleapis.com/auth/admin.reports.audit.readonly' try: client_id = self.args.get('client_id') client_secret = self.args.get('client_secret') auth_code = self.args.get('auth_code') storage = Storage(app_dir + os.path.sep + 'google_drive_creds') flow = OAuth2WebServerFlow(client_id, client_secret, oauth_scope, redirect_uri) credentials = flow.step2_exchange(auth_code) logger.debug("Obtained OAuth2 credentials!") storage.put(credentials) except Exception, e: logger.exception(e) self.response.write(e) # listen to all verbs
Example #24
Source File: appengine.py From splunk-ref-pas-code with Apache License 2.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow(self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #25
Source File: appengine.py From earthengine with MIT License | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow(self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #26
Source File: appengine.py From data with GNU General Public License v3.0 | 6 votes |
def _create_flow(self, request_handler): """Create the Flow object. The Flow is calculated lazily since we don't know where this app is running until it receives a request, at which point redirect_uri can be calculated and then the Flow object can be constructed. Args: request_handler: webapp.RequestHandler, the request handler. """ if self.flow is None: redirect_uri = request_handler.request.relative_url( self._callback_path) # Usually /oauth2callback self.flow = OAuth2WebServerFlow(self._client_id, self._client_secret, self._scope, redirect_uri=redirect_uri, user_agent=self._user_agent, auth_uri=self._auth_uri, token_uri=self._token_uri, revoke_uri=self._revoke_uri, **self._kwargs)
Example #27
Source File: auth_google.py From fitbit-googlefit with GNU General Public License v3.0 | 6 votes |
def main(): # Arguments parsing parser = argparse.ArgumentParser("Client ID and Secret are mandatory arguments") parser.add_argument("-i", "--id", required=True, help="Client id", metavar='<client-id>') parser.add_argument("-s", "--secret", required=True, help="Client secret", metavar='<client-secret>') parser.add_argument("-c", "--console", default=False, help="Authenticate only using console (for headless systems)", action="store_true") args = parser.parse_args() # Scopes of authorization activity = "https://www.googleapis.com/auth/fitness.activity.write" body = "https://www.googleapis.com/auth/fitness.body.write" location = "https://www.googleapis.com/auth/fitness.location.write" scopes = activity + " " + body + " " + location flow = OAuth2WebServerFlow(args.id, args.secret, scopes) storage = Storage('google.json') flags = ['--noauth_local_webserver'] if args.console else [] run_flow(flow, storage, argparser.parse_args(flags))
Example #28
Source File: views.py From CLAtoolkit with GNU General Public License v3.0 | 5 votes |
def get_youtubechannel(request): youtube_plugin = settings.DATAINTEGRATION_PLUGINS[xapi_settings.PLATFORM_YOUTUBE] # redirecturl= 'http://' + get_current_site(request).domain + '/dataintegration/showyoutubechannel' redirecturl = get_youtube_user_channel_url(request) FLOW_YOUTUBE = OAuth2WebServerFlow( client_id=os.environ.get("YOUTUBE_CLIENT_ID"), client_secret=os.environ.get("YOUTUBE_CLIENT_SECRET"), scope=youtube_plugin.scope, redirect_uri=redirecturl ) authUri = FLOW_YOUTUBE.step1_get_authorize_url() #Redirect to REDIRECT_URI return HttpResponseRedirect(authUri)
Example #29
Source File: views.py From CLAtoolkit with GNU General Public License v3.0 | 5 votes |
def showyoutubechannel(request): youtube_plugin = settings.DATAINTEGRATION_PLUGINS[xapi_settings.PLATFORM_YOUTUBE] # redirecturl= 'http://' + get_current_site(request).domain + '/dataintegration/showyoutubechannel' redirecturl = get_youtube_user_channel_url(request) FLOW_YOUTUBE = OAuth2WebServerFlow( client_id=os.environ.get("YOUTUBE_CLIENT_ID"), client_secret=os.environ.get("YOUTUBE_CLIENT_SECRET"), scope=youtube_plugin.scope, redirect_uri=redirecturl ) http = googleAuth(request, FLOW_YOUTUBE) channel_url = youtube_getpersonalchannel(request, http) html_response = HttpResponse() if channel_url: # Automatically set user's channel url in the textbox script_set_id = 'window.opener.$("#id_google_account_name").val("http://www.youtube.com/channel/%s");' % (channel_url) script_set_msg = 'window.opener.$("#youtube_channel_url_msg").html("%s");' % ('Got your YouTube channel URL!') # script_set_token = 'window.opener.$("#github_token").val("%s");' % (token) script_set_msg = script_set_msg + 'window.opener.$("#youtube_channel_url_msg").show();' script_set_msg = script_set_msg + 'window.opener.$("#youtube_auth_link").hide();' # Script for closing the popup window automatically html_resp = '<script>' + script_set_id + script_set_msg + 'window.close();</script>' html_response = HttpResponse() html_response.write(html_resp) else: html_response.write('No Channel url found. Please ensure that you are logged into YouTube and try again.') return html_response
Example #30
Source File: auth_google.py From BS440 with MIT License | 5 votes |
def main(): client_id = sys.argv[1] client_secret = sys.argv[2] scope = sys.argv[3] flow = OAuth2WebServerFlow(client_id, client_secret, scope) storage = Storage('google.json') flags = argparser.parse_args([]) run_flow(flow, storage, flags)