youtube ask for channel selection while authenticating - javascript

I am using javascript sdk to authenticate google. In my webapp I am trying to upload video to youtube.
A youtube account might have multiple channels and I want to select the channel and send the information to the server with access token and all required value to upload a video.
I can authenticate a user from google but how can I display the youtube channel selection ui and also if there is no channel in the account I want to show error.
I have gone through youtube api but I found it very complex
Need help

YouTube is very different from other Google APIs. When your user authenticate your application they are not just authenticating you to YouTube you are actually getting authenticated to a single YouTube channel.
If you want to see the account selection you are going to have to force them to re authenticate you will then get a new access token associated to the channel that they pick.
prompt=consent should force them to re-authenticate but that depends on how you have implemented things.
Recap:
If a user has 5 channels you will to authenticate them once for each channel you will then have five access tokens each of which grants your application access to a single channel.

Related

Upload video to my channel via Youtube API V3 (Javascript)

To make things more clear:
Account A - The account that i used to create the api credentials and where i have the channel that i want to receive the uploaded videos
Account B - The account that i used to test the video uploading
I reproduced this example from google and replaced the client ID with mine (from Account A). It asks first for authentication (i logged in from Account B) and then i picked up a local video to upload. The result: Uploaded the video to Account B instead of the account A.
Screenshot
How can i make it to upload to Account A?
I also tried to do it without oauth by using just an API Key but without success (i didn't found an example for that ) so if someone can help with this method i'm grateful.
Note: I will implement this in a wordpress site page, where only users with editor role can access it.
You are aware that application credentials have nothing to do with your user account right your still going to have to authenticated the application to access YouTube
If you want to upload to account b then login to account b when you're application request access. If you want to upload to account a then login and authenticate your application to account a.
your application can only upload to the account of the current authenticated user.

YouTube API | Javascript- Upload video to a constant channel bypassing login.

I'm building a web application that allows a specific user to upload videos to a YouTube account through the use of the YouTube API. The uploading of videos will be done by only one person & videos will be uploaded only to one account. If the YouTube account is already authorized by the app to manage the channel etc, how can I setup the application in such a way that the user bypasses the authentication/login screen every time he/she needs to upload a video? (That is when the user exits and re-enters application.)
While reading, a solution I stumbled upon a solution which was to use a refresh token but I don't know how to integrate it with the code I have currently. The code I'm using is the one available on the Google Developers site, link below.
https://developers.google.com/youtube/v3/code_samples/javascript#upload-a-video
Please note that I've gone through & read all similar questions on this forum but none provides Javascript help/solution.
Normally i would say that you should use a service account which would allow you to preauthorize the access to YouTube. However the YouTube API does not support service accounts so your going to have to do it the hard way.
You will need to authenticate your application once and save the refresh token. Then you will be able to use the refresh token again later to get a new access token. You will have to watch this application refresh tokens can expire its rare but it can happen so you should have something set up that will allow you to quickly reauthenticate it and save a new refresh token.
To my knowledge it is not possible to get a refresh token with JavaScript your going to have to use a server sided language like node.js for example. This tutorial should show you how to get offline access with node js. Node.js Quickstart

Youtube API javascript upload video to predefined channel

I wanted to ask you if I could implement javascript youtube API in order to upload videos to a single predefined channel, without the need of authenticating.
Based from this thread, it might not be possible if you are trying to get the server to authorize on your behalf say if you were allowing people to upload videos to a single shared channel. You'd need to do some way of authorizing the client locally on the server which then has the server authorized to the YouTube account.
However, you may refer with this post which stated that if you don't want authentication for each upload process, you can use refresh token.

Using Google sign in api - manage users permission

I understand that I can use Google Sign in button and grant access to my website only to users from my domain (using metadata tag).
My question is, once a user is logged in can I control the pages that he/she sees. For example I want some users to be admins but other users to be regular users. Each user 'type' will have access to different set of pages.
Thanks,
Shay
Google's sign-in API can only authenticate users, it can't manage authorizations. For that you'll need to either use a cloud service like Cognito (which supports Google sign-in as a federated login provider for its own temporarily-generated identity) or write your own server-side access manager that associates the sign-in token with specific permissions, and then handles the authorization of user requests.

Upload videos to youtube without having the user sign in

I want to create a web application that allows the users to upload videos to a specific YouTube account. The users do not have gmail accounts and they have to access YouTube via one login. Is there a way for me to achieve this without having the users to login to the Google account.
I have tried the samples provided by the YouTube API. These first show the Google+ log in screen for the users to enter the credentials. What i want, is for the application to login, without the users knowing it. Is it possible to implement a way for the application to signin to the account without its users realizing it. Please provide me with a soution. So far I have tried the YouTube JavaScript API.
Thank you in advance!
YouTube is dependent on gmail emails now. They switched a while back.
You should be able to have them login once, and then your application could remember their login.
YouTube's authentication is going to need them to login so the OAuth token can be handed off.

Categories

Resources