Upload video to my channel via Youtube API V3 (Javascript) - 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.

Related

Automate Google Calendar Access Authorization Code Retrieval - NodeJS

I'm new to NodeJS and any help will really be appreciated.
I am currently making an application to access a user’s Google Calendar.
Right now I am using the code snippet for NodeJS from the following link, using my project's credentials.
https://developers.google.com/calendar/quickstart/nodejs
After running the script there is a link which directs the user to the Google Login page, where the user can login from a chosen account and then authorize Full Calendar access to the app.
Upon authorizing Calendar access to the application, the user is presented with a Unique code which must be copied into the terminal (prompted by the script) which then generates a token and stores it in token.json.
I want to automate the retrieval of the unique code (generated for the user upon granting access) without the user having to copy the code and paste it in the terminal.
Any help on this would be greatly appreciated!
Also, the page that shows the unique token to be copied and the steps preceding have been shown in the attached screenshots.
Step 1
Step 2
Step 3
Step 4
You need to use a Service Account. They are like "dummy users" which don't require user interaction to be authorized. You will have to grant your users access to the Service Account.
You can follow this guide to set it up:
Open the Service accounts page.
If prompted, select a project, or create a new one.
Click + Create service account.
Under Service account details, type a name, ID, and description for the service account, then click Create.
Optional: Under Service account permissions, select the IAM roles to grant to the service account, then click Continue.
Optional: Under Grant users access to this service account, add the users or groups that are allowed to use and manage the service account.
Click + Create key, then click Create.
Then, use the NodeJS Service Account guide to use the new Credentials.
Instead of Service Accounts, you can also do it by saving the Refresh Token to request new Access Tokens programatically, without user interaction. See this documentation.

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 ask for channel selection while authenticating

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.

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.

How can I hook up facebook connect with our site's login?

I want to implement something similar to what Digg has done.
When the user logs in for the first time, I want it to force them to create an account on my site.
More importantly I want to know how to log a user into my site when they login with facebook connect. If they login with facebook connect, they still haven't provided me the password to their account on my site, so I can't use username/password to log them into my site. How do they do this on Digg or sites similar to this?
Facebook's process flow can definitely be a bit confusing. Take a step back from the details and the API, and look at the overall flow here:
Facebook Connect will tell you that a user is logged into Facebook, and give you their Facebook ID. You can validate that ID against Facebook using Facebook Connect to make sure it is properly logged in. Once this is done, you don't need a user name and password. As long as you trust that Facebook has authenticated the person properly, they are the only ones that can come to your site using that Facebook ID. That is enough information to start an authenticated session based around a local account that is associated with that ID.
The process you should follow is like this:
User logs in to your site with
Facebook Connect for the first time
You notice that you don't have a local account associated with that
Facebook ID, and prompt them to
enter local account information
You save that information along with their Facebook ID
The next time you see that Facebook ID (and validate that it is
logged into Facebook using the
Facebook API), you can start up a
local session using the associated
account.
Basically you end up with two separate methods of authentication: a Facebook Connect ID check, or the regular username/password login on your site. Either one should have the end result of starting a local authenticated session.
Hope that helps.

Categories

Resources