last day (20 days later) » 

11:12 PM
1
A: Node.js: Setting video title and description using YouTube Data API

stvarYou have to acknowledge that calling the Videos.update API endpoint has to be done as shown below: Case #1: Not updating snippet.title and snippet.description const res = await youtube.videos.update({ part: 'id,localizations', id: 'VIDEO_ID', requestBody: { localizations: { ...

 
Thanks! Seems that is the right direction.... However I do not get an result on res0.... I got : { items: [] } TypeError: Cannot read property 'snippet' of undefined // at line const prev = res0.data.items[0].snippet;
 
Please check that VIDEO_ID is the ID of an existing video. The video IDs are of form ^[0-9a-zA-Z_-]{11}$ (though not documented officially as such).
 
Yes, sorry I mistyped the video ID... I correctly get the category ID, but fails on the youtube.videos.update call, I get now : GaxiosError: Forbidden. First call OK (videos list).
Also says : at async OAuth2Client.requestAsync (C:\MyData\Youtube\API\youtube_node\node_modules\google-auth‌​-library\build\src\a‌​uth\oauth2client.js:‌​343:18)
 
You have to have your project enabled on one of the scopes listed here; and you have to be the owner of that video.
 
I think the problem is that the project is still on test mode, may be that? I have to verify it in order to work , right?
 
11:12 PM
No, I don't think so. But it's true that, when, within Google developers console, one sets his/her app to be in testing mode, then every 7 days he/she has to rerun to successful completion an OAuth authentication/authorization flow (for to get new credentials data, i.e. a new refresh token).
 
In that case I have asked for googleapis.com/auth/youtubepartner permission also googleapis.com/auth/youtube but It says "approval pending" ....
 
Auditing your app by Google is imposed when you'll need to upload videos programmatically, i.e. when issuing calls to Videos.insert API endpoint.
The scope https://www.googleapis.com/auth/youtube suffices. The other one implies things that apply to YouTube content partners; I deem that's not your case.
 
OK. Then I'll remove other permissions but googleapis.com/auth/youtube. Thanks for your help.
Leavng only googleapis.com/auth/youtube still asks for verification as it's a sensible permission....
 
Then try to not having your app set as being in testing mode. (I guess this behavior is kinda new; could you post a screenshot somewhere that shows it?)
Also, you may well play around with Google's Developers OAuth 2.0 Playground. It could be useful for understanding and troubleshooting (at times) these kinds of ussue.
 
11:12 PM
Indeed, after I myself created a web project, being on the OAuth consent screen page, after pushing the button Publish App, I've got a pop-up window entitled Push to Production? with CANCEL and CONFIRM buttons at the bottom of it.
 
I'll try to delete and recreate from scratch
 
Question: are you going to use your Node.js app from command line? If yes, then try creating a new project of type Desktop, CLI. This way, I hope, the verification process will get postponed.
 
OK. Yes, it's from Windows CLI... I'll try that
I modified the original question, now Have an authentification error.... Thanks again for you help!
Where should I insert the API KEY on my code?
 
Upon having created a new project of type CLI, have you downloaded its corresponding client secret JSON file?
 
yes, but modified the redirect_uri as it gave an error
 
11:12 PM
Since you're going to modify metadata associated to videos you own, you'll not going to use API keys, but credentials data (refresh token and access token) obtained upon running to successful completion an OAuth flow from within your app.
Please have your redirect uri matching the one you've set within Google developers console.
 
On a Desktop app I do not see where to specify the redirect uri....
originally is set to "redirect_uris":["urn:ietf:wg:oauth:2.0:oob","[localhost"]](localhost"]) on secret json
but got that error: Error: The provided keyfile does not define a valid redirect URI. There must be at least one redirect URI defined, and this sample assumes it redirects to 'localhost:3000/oauth2callback'. Please edit your keyfile, and add a 'redirect_uris' section. For example: "redirect_uris": [ "localhost:3000/oauth2callback" ]
 
This is a conflicting situation: your downloaded client secret JSON file has an redirect URI set (by default, by the developers console) to http://localhost; but the implementation of authenticate seems to need that URI to be http://localhost:3000/oauth2callback.
 
originally is set to "redirect_uris":["urn:ietf:wg:oauth:2.0:oob","localhost"] on secret json but got an error
 
Don't know yet how to fix this conflict. The solution should be found on the Node.js' side; that is within your app and/or within the library code your app is using. I'll look into it further, but cannot tell a priori whether I'll succeed at it or not. (Unfortunately, I'll have to go offline for a couple of hours.)
 
ok, thanks.....
 
11:12 PM
In the mean time, get back to your other project that's of type web application and do try creating new OAuth credentials (while having that project's Publishing status as Testing). This way, you'll have the possibility to set the redirect URI to the needed http://localhost:3000/oauth2callback under the section Authorized redirect URIs, the button ADD URI, on the page Create OAuth client ID.
Did the above worked?
I've looked into the sources of Google Local Auth: Node.js Client. The code indicates the the URL http://localhost:3000/oauth2callback is indeed needed since the function authenticate starts a web server for to receive the (intermediate) authentication code from Google's server during the OAuth flow.
Now, if you cannot succeed running your app based on the web app project as outlined above, then I'd suggest to replace your entire OAuth code with something as shown by the sample code of Node.js Quickstart.
Then run this modified code under the JSON file associated to the other project you created, namely that which is of type Desktop (that which got the redirect URI set to htttp://localhost).
Please note that this later (modified) app of yours would not run a web server at all. But you'll have apply some manual work: copy the URL the app passes to your under the prompt Authorize this app by visiting this url:, for then to paste that URL into a browser. Upon the authorization flow within the browser, the Google server will redirect you to http://localhost under an URL that has a parameter code=...; copy that code for to paste it under your app's prompt Enter the code from that page here:.
This manual activity is standard documented behavior for Desktop apps; see for example the section Step 4: Run the sample of the Node.js Quickstart page I already mentioned.
@Marco Martin: How did things worked?
 
I still have same problem..... I just asked google to verify my app but that will take 6 weeks! I cannot see how to use youtube permission without verification! Just show that I have "user type" as "external not "internal", cannot choose internal thought. Might this affect?
 
OK. Then you'll have to make your app work as a Desktop app, as I described above. That does not require verification. (Only when you want to start uploading videos; that's another story.) Please follow the descriptions I made above. That's a path that will very likely be successful.
 
The new method you give me today, does works as only uses googleapis.com/auth/youtube.readonly scope, that worked well also on the web app. The problem is googleapis.com/auth/youtube scope...
 
I see: you're confused by the sample code having this scope https://www.googleapis.com/auth/youtube.readonly; but your modified app will have this modified to the required https://www.googleapis.com/auth/youtube. That's no issue.
Also, I should remind you that the local URI (that which get passed on to the Google server during the OAuth flow) has to be identical to the one the Google server already knows about from your Google project's configuration. Therefore, modifying locally the client secret JSON file's redirect_uris property would lead the OAuth flow to failure.
 
yes, it's identical
 
11:12 PM
@Marco Martin: Is everything OK?
 
No, still not working... I think the app verification is mandatory..
 
Is not: I myself am currently using credentials data on an Google project (created within the developers console) that is type Desktop, CLI. Please describe your current problem.
I suggest to verify the downloaded client secret JSON file that you're running your modified app on: it should look like the following {"installed":{"client_id":"xxx.apps.googleusercontent.com","‌​project_id":"...","a‌​uth_uri":"https://ac‌​counts.google.com/o/‌​oauth2/auth","token_‌​uri":"https://oauth2‌​.googleapis.com/toke‌​n","auth_provider_x5‌​09_cert_url":"https:‌​//www.googleapis.com‌​/oauth2/v1/certs","c‌​lient_secret":"...",‌​"redirect_uris":["ur‌​n:ietf:wg:oauth:2.0:‌​oob","http://localho‌​st"]}}
Then you should run to successful completion an OAuth flow (proceeding with the manual copy-paste work I described above).
 

  last day (20 days later) »