Youtube unauthorized error when uploading videos through api - youtube-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?

Related

Permission denied on returning captions to YouTube

I have an integration with YouTube to return captions to videos of different YouTube accounts, and I use the YouTube API for this.
The thing is that some accounts are not being authorized to return captions. I made some investigation and I noticed some stuffs:
The oauth app seems to intermittently give an unverified warning to users trying to authorize the application to access their youtube account via api;
Even the users authorizing their accounts, when I try to return the captions I get an unauthorized message;
By digging more, I noticed that the access token had its expiration date to the moment of authorization.
The token is not being refreshed, which should be done by the refresh token, and seems to be not working.
Did someone had problems like that? How did you solved? I already tried to get in touch with YouTube support, but they could not give me a solution or a path to do a better investigation.
I was trying getting in touch with YouTube, but it seems that their technical support only replies on Stackoverflow.
Google saying that the app was not verified
Status of verified application

How to authorize my application with Youku to upload videos to end user's account?

I am working on desktop video editing application. In this app I need to implement Youku video uploading feature. For this purpose I registered my app on https://cloud.youku.com and got the ClientId to use the Video Upload API.
The official documentation (Chinese) says that I need access and refresh tokens to use the Upload API. Using the Upload API with manually generated access token I managed to upload videos to my own Youku account.
However, in my application I need to upload videos to an end user's account. According to the answer on How to get youku access_token I am trying to open the following URL to authorize my app in the end user's account.
https://openapi.youku.com/v2/oauth2/authorize?state=&redirect_uri=https%3A%2F%2Fispringsolutions.com&response_type=code&client_id={MYAPPCLIENTID}.
However I am getting the following error response:
code=1005&type=SystemException&description=Client+id+invalid
I am using the same ClientId that I used to upload videos to my account.
I also found the following document http://api.sandbox.yes.youku.com/open_upload.html (Chinese, can be Google-translated) mentioning the different authorization URL https://api.youku.com/oauth2/authorize?client_id={client_id}&response_type=code&redirect_uri={CALLBACK_URL}&state=. However this API is seems to be crossed out since September, 2015.
So, is it possible today to authorize a custom application in end user's account on Youku for video uploading? I have two hypotheses:
Youku have removed the ability to authorize third party applications to upload videos to an end user's account
or
The third party application have to pass a sort of verification process to get authorized in end user's account
I've finally got a response from Youku on this question.
hello 你好,
先解答您的问题
1.https://openapi.youku.com/v2/oauth2/authorize?这个接口已经废弃了,建议使用此文档中的上传方案https://cloud.youku.com/docs?id=109
2.您可以使用一个accesstoken,将您平台的视频统一上传至优酷同一个账号中,方便您管理内容
谢谢
Which is translated by Google as:
hello,
Answer your question first
https://openapi.youku.com/v2/oauth2/authorize? This interface has been deprecated, it is recommended to use the upload scheme in this document https://cloud.youku.com/docs?id=109
You can use one accesstoken to upload videos of your platform to the same account on Youku, which is convenient for you to manage content
Thank you
So, I can conclude that it is currently not possible to authorize your application with Youku to upload a video to another user account.
Youku Upload API is now suitable only for batch upload of videos to your account. You can't use the Youku Upload API in your application to let the application automatically upload a video to an end-user account. Users have to upload their videos manually to Youku via Web Browser.

YouTube API v3 invalid grant after generating new refresh token

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!

Downloading captions using Youtube v3 API

While attempting to download captions for a video (not owned by me) using OAuth 2.0 authorization, I am receiving a 403 Forbidden error which states "The permissions associated with the request are not sufficient to download the caption track. The request might not be properly authorized, or the video order might not have enabled third-party contributions for this caption." On further research, I have found other people also faced the same issue as this, and have not been able to download captions unless the video was uploaded from their own account.
Is there still no possible way of downloading a caption track from a video? How exactly do sites like keepsubs(dot)com, manage to do this then?
Captions: download documentation
Authorization
This request requires authorization with at least one of the following
scopes (read more about authentication and authorization).
Scope https://www.googleapis.com/auth/youtube.force-ssl
https://www.googleapis.com/auth/youtubepartner
The owner of the video will have to authenticate your application using Oauth2 with one of those scopes.
The V3 API doesn't allow this. You would have to make a request to youtube, load the javascript, turn subtitles on, then look for the https://www.youtube.com/api/timedtext request.
It uses a signature, key, and some other items in the query string that the request will fail without. You can make the request to the timedtext endpoint from the server using any http requestor.
Other thoughts: You might be able to get that request to be loaded automatically by having subtitles automatically turned on in the query string somehow. This would make your life a lot easier.
You could also try to replicate how they create the key and signature, and then just create it yourself. I bet it uses the video id in some manner.

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