YouTube Data API v3 video upload 403 forbidden: YouTubeSignUpRequired - youtube-api

I am trying to use the new YouTube Data API v3 to upload video to youtube on Android, but I am getting a 403 forbidden error:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403 Forbidden
01-22 00:10:41.716: WARN/System.err(5209): {
01-22 00:10:41.716: WARN/System.err(5209): "code" : 403,
01-22 00:10:41.716: WARN/System.err(5209): "errors" : [ {
01-22 00:10:41.716: WARN/System.err(5209): "domain" : "youtube.header",
01-22 00:10:41.716: WARN/System.err(5209): "location" : "Authorization",
01-22 00:10:41.716: WARN/System.err(5209): "locationType" : "header",
01-22 00:10:41.716: WARN/System.err(5209): "message" : "Forbidden",
01-22 00:10:41.716: WARN/System.err(5209): "reason" : "youtubeSignupRequired"
01-22 00:10:41.716: WARN/System.err(5209): } ],
01-22 00:10:41.720: WARN/System.err(5209): "message" : "Forbidden"
01-22 00:10:41.720: WARN/System.err(5209): }
The code is as follow:
I got the OAuth2.0 credential, and I used it to create an instance of youtube:
YouTube youTube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), credential)
.setApplicationName("testapp/1.0")
.build();
# ... creating video to save space ...
youTube.videos().insert("snippet,statistics,status", video, mediaContent).execute();
Any Idea?
Thanks

It sounds like you're trying to upload a video into an unlinked Google account. That scenario is covered in this blog post to some extent, though the focus of that post is v2.1 of the API.
When it comes to v3, you still can't upload a video into an unlinked Google account, and there's no API call to allow a user to programmatically link an account. Your best bet would be to take the user to http://m.youtube.com/create_channel and they can take care of the linking there from a browser, at which point they'd have to return to your app and attempt the upload again.

You can use this mobile workflow in a WebView to have the user create the channel without leaving your app:
https://m.youtube.com/create_channel?chromeless=1&next=/channel_creation_done
To process will take the user to /channel_creation_done once completed, and you can close the WebView then. You can find more information about the workflow here: https://developers.google.com/youtube/create-channel

I solved it and my answer is here:
How to insert video youtube api v3 through service account with ruby
Enjoy!
The error you are getting is because you didn't add the person tag with the email to upload the movie to. It is all solved and working if you use the code in my answer

Related

Google Business Profile Performance API PERMISSION_DENIED

I'm currently working on migrating from the Google My business V4.9 to the Business Profile Performance API .
For number of credentials the changes are working as expected but for others, there is a problem with making the request as I'm getting this error.
GET https://businessprofileperformance.googleapis.com/v1/locations/****:getDailyMetricsTimeSeries?dailyMetric=CALL_CLICKS&dailyRange.endDate.day=8&dailyRange.endDate.month=1&dailyRange.endDate.year=2023&dailyRange.startDate.day=31&dailyRange.startDate.month=12&dailyRange.startDate.year=2022
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "The caller does not have permission",
"reason" : "forbidden"
} ],
"message" : "The caller does not have permission",
"status" : "PERMISSION_DENIED"
}
Worth to mention that for the same credentials and scope everything is working with the older endpoints.
I'm currently using https://www.googleapis.com/auth/plus.business.manage, can this be the problem as it has been deprecated(But you can still use it) and now there is https://www.googleapis.com/auth/business.manage instead?
UPDATE
It seems that before it simply returned an empty list of reports for this location, and now it's throwing an exception.

Datorama & DV360 Data Stream

I am getting an error when trying to connect my DV360 account to Datorama Stream. I know for sure my credentials arent the problem because I am granted acces when using Google Analytics or Adwords with the same account but specifically with DV360 I get this:
Provider's Internal Error
403 Forbidden GET https://displayvideo.googleapis.com/v1/advertisers?pageSize=100&partnerId=4611731
{ "code" : 403, "errors" :
[ { "domain" : "global",
"message" : "No permission for attempted operation on PARTNER with ID \"4611731\".",
"reason" : "forbidden" } ],
"message" : "No permission for attempted operation on PARTNER with ID \"4611731\".", "status" : "PERMISSION_DENIED" }
Does anyone know what the problem might be? would it be something on the web app side?
Cheers,

Calling graph API to access oneDrive (office365) via another REST service

We want to upload files via a REST service to our oneDrive. In the REST service we are calling Microsoft Graph API but I am getting the 401 error, which I guess because of authorisation issue, I am wondering what is the best approach here?
The whole process works nicely if on our web-application.
I granted App permission in the Azure Active Directory portal and confirmed the consent at
https://login.microsoftonline.com/<tenant>/adminconsent?client_id=<client-id>
Then tried to get token
url = "https://login.microsoftonline.com/<tenant>/oauth2/v2.0/token"
"client_id": credential.clientid
"client_secret", credential.clientsecret
"scope", "https%3A%2F%2Fgraph.microsoft.com%2F.default"
"grant_type", "client_credentials"
I was still getting 401 error.
Then I fixed the permissions, now I get the access_token, now I first checked if a file exists in specific folder in oneDrive, if not then upload the file.
But now I get the following error:
{
"statuscode": 403,
"body": "{\r\n \"error\": {\r\n \"code\": \"AccessDenied\",\r\n \"message\": \"Either scp or roles claim need to be present in the token.\",\r\n \"innerError\": {\r\n \"date\": \"2020-08-13T10:12:33\",\r\n \"request-id\": \"338a2758-m7e0-4289-bnna-45pb14c79efa\"\r\n }\r\n }\r\n}"
}
I used the following API for checking if a file exists:
"https://graph.microsoft.com/v1.0/sites/<siteid>/drive/root:/<filePath>:/children"
I am not sure what roles/permission I need to set.

YouTube Content ID API returns Forbidden error

I've created a service account for use with the YouTube Content ID API, I'm following the steps under Set up your service account on:
https://developers.google.com/youtube/partner/guides/oauth2_for_service_accounts
The steps seem to be a bit outdated, I am not able to find YouTube Content ID API in Developer console.
I am able to upload a video on a channel.
Well, when I'm making requests using this service account, I'm getting forbidden errors. For example the below error is when I'm trying to get a list of content owners.
error::::::{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission: Request had insufficient authentication scopes."
}
],
"code": 403,
"message": "Insufficient Permission: Request had insufficient authentication scopes."
}
}
Here's the PHP code:
$client = new Google_Client();
$client->setAccessType("offline");
$client->setApprovalPrompt("force");
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);
$client->setScopes(array('https://www.googleapis.com/auth/youtube', 'https://www.googleapis.com/auth/youtubepartner'));
$youtube = new Google_Service_YouTube($client);
$youtubePartner = new Google_Service_YouTubePartner($client);
$contentOwnersListResponse = $youtubePartner->contentOwners->listContentOwners(
array('fetchMine' => true));
$contentOwnerId = $contentOwnersListResponse['items'][0]['id'];
You have mentioned that you cannot see the "YouTube Content ID API" in your Google Developers Console, I think you need to check the YouTube Partner Program. Please do take note that "The YouTube Content ID API is intended for use by YouTube content partners and is not accessible to all developers or to all YouTube users". It was stated in the note at the top most of the page.

API key no longer working, but don't know what account it is aligned with

When calling the YouTube API, we've started getting error responses with the following message:
{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "Project 418176253215 has been scheduled for deletion and cannot be used for API calls. Visit https://console.developers.google.com/iam-admin/projects?pendingDeletion=true to undelete the project.",
"reason" : "accessNotConfigured",
"extendedHelp" : "https://console.developers.google.com/iam-admin/projects?pendingDeletion=true"
} ],
"message" : "Project 418176253215 has been scheduled for deletion and cannot be used for API calls. Visit https://console.developers.google.com/iam-admin/projects?pendingDeletion=true to undelete the project."
}
However, I cannot use the link provided because I can't find what account was used to create the key for the API (I've inherited the code).
Is there a way to discover what account aligns with a YouTube API key?
There is no documentation in Youtube API which states how to do this because if you own the API key, logging in the Google Dev Console under the given project name should easily display all the API keys being used.

Resources