YouTube API v3 invalid grant after generating new refresh token - youtube-api

We have an application which uses YouTube Data API v3 so we could be able to upload and manage videos on YouTube. For several days
we have not been able to upload videos in YouTube, nor to list corresponding playlists from the channel or to make any other actions which require making requests to YouTube Data API.
When we try to list the playlists or to get a certain video by its Id or to upload a new video we get the following error message:
Error {Error:"invalid_grant", Description:"Bad Request", Uri:""} Google.Apis.Auth.OAuth2.Responses.TokenErrorResponse
We generated new refresh token from YouTube API but when we use it, we get the same error.
Then we created a new application in YouTube developers page with new credentials and newly generated refresh token but we still are getting the same error.
We think the reason the previous refresh token has become invalid is that the last time it was used is 7 months ago (the Google's documentation indicates that a refresh token expires if "The refresh token has not been used for six months.").
Does somebody know why are not we able to use the newly generated refresh token and what should we do in order to make a successful request to the YouTube API?
Thanks in advance!

Related

No longer able to get watched history of youtube user using Youtube API?

All the related SO questions and answers say to use the playlist ID returned in the contentDetails.relatedPlaylists.watchHistory returned by the youtube.channels.list endpoint. That value now always seems to be set to "HL". I'm using an OAuth token to authenticate the request. Is there another way to get the list of recently watched videoes for the authenticated user? I also noticed that the list of watched videos no longer appears on the user's YouTube home page, just recommended videoes. Am I just SOL or is there some new way to access the watch history?

Unable to OAuth with account that owns YouTube channel

I have a google account that I was previously uploading videos to using the v2 YouTube API. This account I guess has two accounts linked to it, because when I go through OAuth flows I have to choose which account.
The 1st account, the one I setup the API in developer console, gives me the option to authorize YouTube API controls.
The 2nd account, the one that actually is the YouTube channel, only says that I'm giving my application offline access, there is no permissions specified relating to YouTube.
I did my OAuth using the 1st account, since that one actually listed youtube permissions. Got my refresh token and added it to the application. However, when I go to attempt to insert a video to YouTube I get the following error:
Code 401 Unauthorized: youtubeSignupRequired
It's as though I'm not linking at all to the YouTube channel account even though they are both on the same Google account.
Has anyone encountered this before?
By the way, I know with certainty that my API calls work properly, as we were able to upload from the dev environment. The dev account is only a single account though that owns the channel on the same account as the API.
I was able to resolve this.
It turned out I needed to do the OAuth with the 2nd account, the one for the YouTube channel. Despite it not requesting any permissions related to YouTube and only getting offline access, I was able to successfully upload using the refresh token I received.
Definitely a case of the most illogical solution being the correct one.

Youtube unauthorized error when uploading videos through api

I am using a javascript uploader to upload videos to Youtube. To make API requests I am using an OAuth2.0 access token. This uploader works fine. But once in months it starts to give error Unauthorized by Youtube API. To resolve this issue I have to go to https://accounts.google.com/UnlockCaptcha and click continue then the uploader starts to work again.
I have read about CAPTCHA verification in Youtube API documentation but isn't it just for ClientLogin for installed apps that do not use OAuth2.0 access token?
Also is there a way to permanently off CAPTCHA verification as even I implement some logic in my uploader to handle CAPTCHA verification I will not be able to test it again until it starts to give me error again.
Note: Most of the times video is uploaded 100% and sometimes less than 100% when it gives error. Shouldn't it give error on the first request to API when we are just sending metadata of the video?

How to upload videos to Youtube with api key by V3 .NET

I have some issues with V2 (Error code 400) so I'm trying to move to Youtube Api V3 from V2.
I'm using C# and I've been searching how to upload videos to Youtube with api key on V3 .NET
Where can i find an example,explanation or a document for that?
https://developers.google.com/youtube/v3/code_samples/dotnet#upload_a_video
You need to go through OAuth2. If you are trying to upload into your own account, then this segment explains how to: https://developers.google.com/youtube/v3/guides/moving_to_oauth#standalone
Basically, you go through once and save the token from there.
If you even want to skip that one time as well, you can get a refresh token in OAuth2 Playground with respected scopes and plug it in directly in your code, with client secret and id. That way your script won't need a web browser.
Here's the video explaining this workflow step-by-step.

API - Upload video in PHP to a specific Channel

We're planning on using the YouTube API Data V3 to allow users to upload videos to our channel via PHP. My question is, what are the correct steps in allowing the video to be uploaded on a server, to our Channel? I though that is where the Server or possibly Browser key would come into play?
Currently, I'm able to upload the video, but after the user signs in, it get's uploaded to their Channel. Do we need to store the access token generated by account that we want all the videos to be uploaded to?
You can actually save the refresh token once the account of your server signs in and reuse it in your code, rather than signing in a user every time.
You can do so by getting a refresh token from OAuth2 Playground and setting it in your youtube object.
Here it explains a little more.
And a step by step video.

Resources