I've just started using the Twitter API with the python package Tweepy. Everything was working fine until ~24 hours I received the following error:
tweepy.errors.Unauthorized: 401 Unauthorized
89 - Invalid or expired token.
I've tried to regenerate these tokens, however, on my developer portal it asks me to Generate not Regenerate. When I click Generate it's creating the exact same Access Token and Access Token Secret. Once I refresh the page, the Access Token & Secret are asking to be generated again.
Related
I'm currently facing an issue with OAuth2 access token. Currently, my app periodically uses the google OAuth2 Tokens to get events from my personal google calendar and is able to add new events to the google calendar. However, an exception occured saying that the token expired. After searching through google, I found out that you cannot set the access token to have no expiry date, and using API key wouldn't work as I cannot then add new events to the google calendar(Is this true ?)
I am using the Credentials.from_user_authorized_files and build from the credentials to access the API. It appears that even when I provide no value in the "access_token" field it still works, that must mean that my refresh token was the one needed and it expired. I read up online that for refresh tokens to be permanent, the app needed verification from google, otherwise it will expire in 7 days. I am unsure on how to solve the issue. I generated a new refresh token and it seemed to work. How do I prevent the refresh token from expiring ? Or is this not a problem with the refresh tokens ? Are there any other way I can make this work without having to manually change the refresh token every 7 days ? Thanks in advance !
I'm having a strange google video intelligence api request error when I run a test with python vcr. I was wondering if anyone else has seen this error, and if so, why we have this and how to solve it?
I use VCR to mock the request to video intelligence api.
I use pytest to run my test.
If I delete the VCR and rerun it runs fine, and if I try running it again after vcr is created it also runs fine. However after a while, (not currently sure if this is hours or days, I will get the error below from running the vcr).
The error is below:-
"Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential.
This is the VCR error
E google.api_core.exceptions.Unauthenticated: 401 Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
<string>:3: Unauthenticated
Assertion failed
Google Vision Intelligence just like other google service, use gRPC to communicate with service backend. Unfortunately, VCR does not support gRPC yet.
The only thing VCR recorded during test is OAuth token (checked the cassettes file VCR generated). When it expired, it will cause the Unauthenticated Error
reference:
Feature request about gRPC support
https://github.com/kevin1024/vcrpy/issues/560
VCR for gRPC (Ruby) https://github.com/btoews/gcr
The error seems to point towards invalid authentication credentials.
There might be two possible scenarios behind this error -
You can follow the below mentioned steps to verify the initial setup configuration you have made :
Solution1- For Custom Service account i.e user-managed service accounts:
If you have created a service account of your own then you will need to generate the keys for that service account.
You also need to set the Environment variables using:
“export GOOGLE_APPLICATION_CREDENTIALS="KEY_PATH”
Solution2- Application Default Credentials are not available:
For Default Service accounts ( projects which have enabled the Compute Engine API will have a Compute Engine default service account which will use the Application Default Credentials ), you can follow the below mentioned steps:
You need to log in using the command : gcloud auth application-default login
If you want to make sure that the authentication process went well then run : gcloud auth application-default print-access-token. You should be able to see an access token.
Access tokens have limited lifetimes. If your application needs access to a Google API beyond the lifetime of a single access token, it can obtain a refresh token. A refresh token allows your application to obtain new access tokens.
Basically gcloud auth application-default login acquires credentials to make them available to the applications in your local machine to use when they are configured to use Application Default Credentials.
I have a Web Api project that I have already configured to use Facebook & Google authentication.
Facebook and Google both have a way of verifying the access token given on authentication step.
Facebook:
https://graph.facebook.com/debug_token?input_token={0}&access_token={1}", accessToken, appToken
These return the app_id or consumer key for my applications.
What is the process for Twitter?
The documentation I have read isn't very clear and what I have tried fails and returns a 404.
Twitter has nothing for verifying any access token similar to the Facebook request you site.
You can only get information about an already authenticated account. You would use account/verify_credentials. However, this endpoint does not return information about your Twitter application.
I am writing a python script to upload videos on youtube using the sample script provided by youtube itself. But I am having this one problem. When my access token is expired, what should I do with the refresh token in order to exchange it for access token (remember I am writing a python script) or how should I exchange refresh token for an access token?
As explained in Refreshing an access token, your application can send a POST request to Google's authorization server that specifies your client ID, your client secret, and the refresh token for the user. The request should also set the grant_type parameter value to refresh_token.
You may want to check this SO post or this thread to know how to implement it using Python.
I try to be specific. I have an app created in facebook When logged manually (go in https://developers.facebook.com/tools/explorer) I get access token type:
"CAAVLIUVx7w0BAPRY9h6IfBKmolxumLLGbvwpLzLh7YG5gWrSOqczbqJM31AnZAW86RPrudLpJ123TKYqZBZCGxR8R1JvBNUQZBCSG2EMXuliaqrgiJKZd213CZA0gQ0c6NdmsJA1mUSrSjxEVLcsZA4OXK8X1hlV9ioWtp20mp81cQJ6YKivh2Jrwt1ZBmffo1YQKUWW6o2WViEuEpQ5suQZDZD"
Then I introduce the access token code in python and works perfectly, but when I close the session on facebook this access token stops working and gives me the error:
OAuthError: [190] Error validating access token: This May be Because the user logged out or May be due to a system error.
My question is: Is there any way to get the access token automatically without human intervention.
(sorry, I speak Spanish and I am using a translator)
Thank you for responding friends.