youtube api 401 error youtubeSigupRequired - python

I am trying to upload a video to Youtube using Youtube API v3 and python and I got the following error.
An HTTP error 401 occurred:
{ "error": { "errors": [ {
"domain": "youtube.header",
"reason": "youtubeSignupRequired",
"message": "Unauthorized",
"locationType": "header",
"location": "Authorization" } ], "code": 401, "message": "Unauthorized" } }
I have created my project, created my Key and Client AOuth 2.0 and google console and downloaded the client_secrets.json.
The code I run is the one provided by Youtube API sample_code to download (here) for python.
If for example I try to do a search using the corresponding sample code and my credentials it works perfectly and I don't know why it doesn't work when I want to upload a vide.
Could you please letting me know what I am doing wrong, please?
Thanks in advance

YouTube Data API - Errors
unauthorized (401) youtubeSignupRequired This error indicates that the
user has an unlinked Google Account, which means that the user has a
Google Account but does not have a YouTube channel. Such users can
access many features that are dependent on user authorization, such as
rating videos or adding videos to a watch_later playlist. However, as
an example, the user would need a YouTube channel to be able to upload
a video. A user who has a Gmail account or an Android device is
certain to have a Google Account but may not have already linked that
Google Account to a YouTube channel.
This error is commonly seen if you try to use the OAuth 2.0 Service
Account flow. YouTube does not support Service Accounts, and if you
attempt to authenticate using a Service Account, you will get this
error.
The YouTube API blog post introducing Google Account support also
discusses the youtubeSignupRequired error in more detail. Although the
blog post explains the error for API version 2.1, the meaning of the
error is still applicable.

Related

Trying to use python to authenticate to WebSite

I'm attempting to authenticate to a website to automate some device configuration.
There is no official API so I'm using "WebSpy" in my browser to watch what URLs are targeted and the payloads being sent.
I'm unable to get initial authentication working with a python post request.
The target url is https://xxxxxx.xxx/authenticate.
The payload I see when logging in from a web browser is.
{ "client_id": xxxxxx,
"username": <plainText username>,
"password": <plainText password>,
"realm": "xxxxx",
"credential_type": "http://auth0.com/oauth/grant-type/password-realm"}
If I replicate all this in a python requests.POST I get back
{ "error": "invalid request",
"error_description": "Unknown client."}
I should mention the "client_id" I'm sending in my python post is just copied from what I see coming from the browser.
I imagine that client ID should be dynamically generated somehow but I don't see where it's coming from.
I should also mention I see some reference to a \callback URL happening after login within the web browser so I'm guessing that is how/when the auth token is being offered.
Can anyone point me in the right direction on all this?
Thank you in advance.

Microsoft Graph API : Unknown Error trying to get Messages in a channel

I'm trying to get Messages from a Team Channel using Python. I'm using the beta endpoint since I know that this functionality is not available in the 1.0 version.
I have all the required permissions:
Type: Application
Permissions: ChannelMessage.Read.All, Group.Read.All, Reports.Read.All
We sent the form Microsoft requires to unlock the API's methods 2 weeks ago, and we had no feedback from them. Should we wait longer? Or the problem is something else?
I'm able to get all of the ID I need (team_id and channel_id), but when I try to get /messages:
https://graph.microsoft.com/beta/teams/" + reporting_team_id + "/channels/" + test_channel_id + "/messages"
I get this Unknown Error:
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "6d6bc5b3-e340-4ea5-ac9b-7f9d2c86caf2",
"date": "2019-12-09T17:02:46"
}
}
}
Per the documentation, you should contact teamsAppPerms#microsoft.com. This API requires special permissions so it isn't something the community can help with.
To request access to these protected APIs, complete the following request form. We review access requests every Wednesday and deploy approvals every Friday. If you would like to provide information in addition to the form, you can contact teamsAppPerms#microsoft.com.
You should send the groupId instead of the teamId to get messages that worked for me.
https://graph.microsoft.com/beta/teams/" + groupId + "/channels/" + encodeURIComponent(channelId)+"/messages?top=5

Neat way to dump model object on google cloud platform from local machine

I have trained a model and I want to deploy it to google cloud platform automatically after it finished training.
I can upload it using this code, but I have also found this other which I found more elegant using the tensorflow api.
from tensorflow import gfile
def dump_object(object_to_dump, output_path):
if not gfile.Exists(output_path):
gfile.MakeDirs(os.path.dirname(output_path))
with gfile.Open(output_path, 'w') as wf:
joblib.dump(object_to_dump, wf)
If I run this on google cloud, it works well. Happy days. But sometimes I want to run this locally let's say for debug locally. Unfortunately if I do that I get a permission denied error:
tensorflow.python.framework.errors_impl.PermissionDeniedError: Error executing an HTTP request: HTTP response code 401 with body '{
"error": {
"code": 401,
"message": "Anonymous caller does not have storage.objects.get access to xxxxxxxx/model_trainer_test.joblib.",
"errors": [
{
"message": "Anonymous caller does not have storage.objects.get access to xxxxxxxx/model_trainer_test.joblib.",
"domain": "global",
"reason": "required",
"locationType": "header",
"locatio'
when reading metadata of gs://xxxxxxx/model_trainer_test.joblib
How would I set the permissions so I that the above code works locally as well?
NOTE: gsutil works and I have correctly set 'GOOGLE_APPLICATION_CREDENTIALS'

YouTube api Error

I am a little confuse! I am trying to develop a script that can pull youtube video id in python. So I went ahead and set up my youtube API key.I use this page to generate the URL.
https://developers.google.com/youtube/v3/docs/search/list
This page generated a sample JSON table with the video ID. But when I put this url in my browser
https://www.googleapis.com/youtube/v3/search?part=id&q=gullybop&key={YOUR_API_KEY}
and yes I filled in my api. I expected to get back a JSON table with the vid ids but I get this instead
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "keyInvalid",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}
I don't think my API key is invalid
I expected when I put the URL in the browser it would return a JSON table with vid ids but instead I got that error above.
Why am I getting this error ?
Thank you Sean
I got JSON results when I accessed this URL with my API Key. So your API key will be invalid nothing else. Try to create another project in API console and create a key without any referrer no server IP. Only generate 1 key in a project. Dont forget to enable YouTube Data API v3 in API manager.

Possible OAuth error using mirror-api-python-cli to connect to Glass from Raspberry Pi

I am trying to use the mirror-api-python-cli command line interface to send timeline cards from Raspberry Pi to Google Glass. I am able to complete the first step which uses the code in get-credentials.py to connect to Google with my application client-id and secret. This code prompts to go to an authorisation URL to obtain a code and upon entering the code it does go on to correctly populate a credentials file with authentication information including access_token and refresh_token.
I am then running the code in the second file, send-to-glass.py, to pass a 'hello world' message to the Google Glass timeline. I am receiving no error message and yet nothing is received by the Glass.
I have created a separate web client for the application using the Google playground and that is able to send cards to the timeline so I know there is no problem on the Google application side.
I have also done a print of the insert_timeline_item call and I think that might be giving a clue as to where the issue lies. The last name value pair in the json response is selfLink which has a url of https://www.googleapis.com/mirror/v1/timeline/xxxxxx where xxxxxx is the id value. If I follow this URL then I get the following:
{ "error": { "errors": [{ "domain": "global", "reason": "required", "message": "Login Required", "locationType": "header", "location": "Authorization" }], "code": 401, "message": "Login Required" }}
---------- UPDATE ----------
I used CURL with a fresh access token, as suggested by Jenny. I must admit I am not familiar with CURL and so it took a few tries to get it to work. First the address was not resolving, so I added www in front of googleapis, then it was complaining that SSL was required so I added https in front, then it complained about the certificate so I added the -k parameter and finally it was trying to resolve Bearer and my access tokens as addresses so I used double quotes instead of single quotes. Please feel free to chuckle at the noob here but possibly this may help someone in the future!
My final curl command looked like this:
{ curl -H "Authorization: Bearer MY-ACCESS-TOKEN" https://www.googleapis.com/mirror/v1/timeline -k }
The result came back with a whole load of json, with what looked like all of the timeline cards I tried to send from the Raspberry Pi. I won't list all the entries, but the top of the json looks like this:
{"kind": "mirror#timeline", "nextPageToken": "LONG-STRING-OF-CHARACTERS",
"items": [
{
"kind": "mirror#timelineItem",
"id": "ITEM-ID",
"selfLink": "https://www.googleapis.com/mirror/v1/timeline/ITEM-ID",
"created": "2014-04-19T01:40:40.597Z",
"updated": "2014-04-19T01:40:40.597Z",
"etag": "1397871640597",
"text": "Hello World",
"notification": {
"level": "DEFAULT"
}
},
{ ... }
So it would appear that somehow the cards are getting to my timeline and yet they are not being delivered to the Glass. As a reminder, using a web client in the playground against the same project I was able to see cards come through to Glass.
So this is a little embarrassing, I have discovered exactly what the problem was. This whole exercise is related to a science fair project my son is doing. He had been programming the Raspberry Pi through WebIDE logged on through his Google Account. I had set up the project to access Glass through my Google account in a separate Chrome browser. Each time I ran get-credentials.py on the Raspberry Pi and it directed me to copy the URL into the browser for approval, I was doing so in my son's browser with his Google account. The credentials were being saved correctly and cards were populating a timeline correctly, but all against my son's Google account and he has no Glass!
I re-ran get-credentials.py, ran the URL in a browser session associated with my own account. Copied the code back to the Pi and now send-to-glass.py works perfectly. My son thinks I'm an idiot and is getting plenty of laughs out of it, but I am pleased to report everything is now working.

Categories