Oauth2 does not return a verification code from quickstart Python script - oauth-2.0

I am a (very) newbe.
Trying to run the Python quickstart sample script from gcloud CLI.
The script is here https://developers.google.com/classroom/quickstart/python
I have the scope set and Oauth2 creds also set to include the scope.
I am unable to authorise/allow the app.
When running the program, the terminal returns an appropriate string for authorisation, which when visited displays the correct page for the scope.
Console output
Consent screen
Once consented a) the authorisation is not granted and b) there is no prompt available in the console to permit the section of the consent url to be pasted or entered. Sample [4/0AWgavde_fLP5wSOsw00bfWWT28gNzBxJMwlYf3r6CU...................].
I would be grateful for any advice if possible.
Many thanks Tony J
I was expecting a prompt beneath the console invitation to enter the auth code - copied from the browser

Related

Google Smart Home Actions add device '[test] ACTION is linked' to immediate 'Something went wrong. Try again'

I am creating a new Google smart home Action, and step one is to create an OAuth 2.0 server for account linking.
https://developers.google.com/actions/identity/oauth2?oauth=code&hl=ko&refresh=1
I have follow all of the steps on the Google documentation under the Auth code UP UNTIL 'start the authentication flow'. I do not know if this is required or where this code would go, but that is a different topic.
However, there is an error with my Authentication page. Linking is done with my iPhone's Google Home app, currently which has the generated [test] prefix. When I click the [test] MYAPP, the service runs through till the redirection correctly. The webpage closes and informs me 'MYAPP is linked. As soon as this notification disapears, a new notification 'Something went wrong. Try again' appears.
Clicking the [test] MYAPP to link any time afterwards leads to a blank webpage that says 'Account now linked', but the MYAPP does not move to the 'linked' portion of the Google Home app.
https://developers.google.com/actions/smarthome/develop/error-logging
After checking the logs, I was initially getting 'OPEN_AUTH_FAILURE' for days. Now, I am getting 'BACKEND_FAILURE'.
What is the next step? How can I debug this?
You can use the Google OAuth Playground to verify that your account linking implementation is working properly. Here is how you can configure this tool to test your endpoint:
Open the Settings gear, change OAuth endpoints to Custom
Enter your authorization and token URLs from the Actions console
Enter your client ID and secret from the Actions console
You won't be authorizing any Google APIs, so for Step 1 you can just enter something like "devices" and click Authorize APIs. You can follow through with the flow in Step 2 to verify that the authorization and token exchange work properly. The tool will report if any errors occur in the flow.
If you can successfully verify your account linking implementation, but you are still seeing errors returned in the Cloud console, please file an issue.

is there a way to automate giving permission to google auth2

we are trying to use google spreadsheets api using oauth2.0 authentication. we used the following code from google api documentation for oauth authentication
def get_credentials():
CLIENT_SECRET_FILE = 'client_secret.json'
SCOPES=[
'https://www.googleapis.com/auth/spreadsheets'
]
APPLICATION_NAME = 'Knab'
home_dir=os.path.expanduser('~')
credential_dir=os.path.join(home_dir,'.credentials')
if not os.path.exists(credential_dir):
os.makedirs(credentials_dir)
credential_path=os.path.join(credential_dir,'knab.json')
store=oauth2client.file.Storage(credential_path)
credentials=store.get()
if not credentials or credentials.invalid:
flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE,SCOPES)
flow.user_agent=APPLICATION_NAME
if flags:
credentials=tools.run_flow(flow,store,flags)
else:
credentials=tools.run(flow,store)
return credentials;
credentials=get_credentials()
http=credentials.authorize(httplib2.Http())
discoveryUrl = ('https://sheets.googleapis.com/$discovery/rest?'
'version=v4')
service = discovery.build('sheets', 'v4', http=http,
discoveryServiceUrl=discoveryUrl)
I have created oauth2 key and passing the json file (client_secret.json), everything works well, but when we run the code on a fresh
machine, it asking us to open a google link and login with credentials and click on allow. We are about to put in amazon lambda as
microservice. So, there shouldn't be manual intervention. I have tried to run with --noauth_local_webserver as command-line argument.
It's asking to visit the url and enter the code. My idea is to SSH a different machine, run a selenium code to open the url and login with
my google credentials, allow permissison and return the code back to the program. I got a idea, but don't know how to implement it,
any suggestions welcome please....

Trouble Implementing OAuth in Google Apps Script (Using Domain-Wide Delegation)

I am trying to run the sample Google Apps Script Service Account OAuth example taken from here:
https://github.com/googlesamples/apps-script-oauth2/blob/master/samples/GoogleServiceAccount.gs and keep getting a server timed-out error. I copied the exact code and just substituted in the private key, client email, and a user email. The example code looks to be current as there was an update to it on July 30th.
I have authorized https://www.googleapis.com/drive/v2/files through the admin console as well as https://accounts.google.com/o/oauth2/token and have listed these as scopes in the admin settings (and domain-wide delegation is enabled). I am using an admin account to run the script.
I keep getting the ubiquitious "Server Timed Out" error and nothing shows up in the Execution Logs.
What might be the problem? Any help would be appreciated. Thanks in advance.
Thanks, Gerardo, for pointing me in the right direction. It turned out that our organization manages permissions for the Google Developer's Console by Organizations (in the Google Admin console). Somehow a few accounts, including mine, were kicked out of the Organization that had permissions to access the Developer's Console. After adding myself back in, the sample worked without problems.

google drive sdk oath2 token

I'm using Ruby quickstart.rb example script provided by https://developers.google.com/drive/quickstart-ruby from a standalone ruby script running under Windows. The script works fine, it launches the browser window, I grant access to the app, paste the token in my console window and get authenticated.
My question is, how can I make this authentication process permanent or at least more long term? Currently I have to authorize the application every time I launch it.
Since the token changes every time a request is made, I'm not able to just save it in the script.
Thanks in advance.
You can use a service account and domain-wide delegation:
https://developers.google.com/drive/delegation

How to get My Twitter Home Timeline in Command Prompt Using PHP and Twitter API

I want to get all my home timeline updates in my windows command line. I can provide the username and password in php code.
How is it possible to get a number of updates when I use following in my command prompt ?
php -f my_tweets.php
Since it's your home_timeline, you need to be authenticated via twitter's website using PIN-based authorization, twitter has stopped using the username:password thingy. This is very possible, you need to set up an app as a desktop client in twitter's developer page then work with Oauth. See
Have you tried Quitter? It's a command line twitter client. There are also several others.

Resources