I'm using OmniAuth in Rails to authenticate users through YouTube OAuth.
I have several Google/YouTube accounts. Two of them log in just fine. Two of them fail with "invalid_credentials".
I'm not entirely sure what that error means; it doesn't appear in the OAuth 2 spec.
I'm successfully logged into all four of these accounts on the Google side using multiple sign-in, so it's not that I'm logging in incorrectly. Two of the accounts work, so it's not that my API key is bad.
What's going on?
I've got the answer.
They're returning invalid_credentials because there's no YouTube account associated with the user who's trying to log in.
But! I did make sure to log into YouTube with those accounts before trying to log into my app. Turns out that's not enough.
In this brave new world, Google users can log into YouTube without actually creating a YouTube account. In the YouTube UI, a YouTube account is a "channel". It is now possible to log into YouTube and not have a channel.
To create a channel, click the user menu (represented by your profile picture) in the top-right corner of the page and click "My Channel". You'll be prompted to create one.
Then you can log in with YouTube OAuth.
Related
I have a youtube channel, CNLohr, http://youtube.com/cnlohr which I use as my primary livestreaming platform. It is distinct from my primary gmail account. My gmail account has its own youtube, but I don't have subscribers or anything on that. CNLohr is a "Brand manager"
My problem is that when authorizing an API application it seems to only apply to my gmail account account. Even if I authorize it as my youtube brand. It's very confusing as I can select my youtube or email account when at youtube but I cannot when visiting the API pages.
For example, if I visit https://developers.google.com/youtube/v3/live/docs/liveChatMessages/list and attempt to use the "Try this API feature" it works flawlessly with my email account - however - there seems to be no way to log onto that site as "CNLohr." When I click the icon up to, it only shows my gmail account and does not show my youtube account as an option.
No matter what I try I can't seem to get livestream or live stream chat IDs from my brand manager account, though it's trivial via my normal gmail account.
How should I proceed if I wish to use the youtube API with my primary 24k subscriber account?
(Scratched out just so no image screevers get my email, it's okay for you guys to know it!)
This issue has been resolved by youtube as of Jan, 2018. Brands are now first-class citizens, and can perform the oauth as expected.
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.
I'm uploading videos to many customers using Google API v3 with PHP client lib, it works for most of them so I guess the issue is not in my code.
For the customers that fail, it always fails, so I believe the problem is with their authentication, however, for these customers I do get categories list with no problem, it's just the video upload that failed.
That made me think it's because of the scopes I used during the authentication, but I used the same scopes for all my customers, those that work and those that don't.
Any idea?
Thanks,
Tan-Tan
A couple of years ago, YouTube accounts changed and became integrated with Google+. After that point, all new accounts were actually Google+ accounts with a linked YouTube channel; however, YouTube accounts that were created before that changeover needed to manually log in and link their YouTube account to their Google+ account. When you try to use the YouTube API to upload a video, if they have one of these legacy accounts that they haven't manually linked, you'll get the error message that you're experiencing.
There's no API call to do the linking for them; so if your app gets that message, you'll have to redirect them to http://m.youtube.com/create_channel and have them link their accounts.
I've got a client who is a business. They are using Google Apps for Business (the paid version), and have created a Google Apps email account. Using this email account, we logged into YouTube and went to create a channel. Because they are a business, we created a BUSINESS YouTube Channel with the associated BUSINESS Google+ Page.
They also have a vendor who is using the YouTube API to upload their videos for them. However when the vendor tries to use the API, they get the error "no linked youtube account". We're thinking that this is because as a Google+ Business Page, the page is not associated with a single Google Account, but rather multiple Google Accounts can be set as "managers" of the page.
When we tried to create a "personal" YouTube Channel/Google+ Page associated with this email address, we tried to put the company name in as the First Name / Last Name and it rejected it because it says that it's a company name and not a real person's name. It also asks for gender and birthdate, and all of those things associated with a person and not a business.
My questions is.... is there a way around this issue? Can you use the YouTube API to upload with a Google+ Business Page and a YouTube Business Channel?
Thanks,
Justin
You should be able to create a Google+ Page and a corresponding YouTube account. Here's a blog post explaining the steps.
To clarify this example, I have a Google+ page (somewhat inactive) for Cloud Hulk, a joke name my old teammates gave me. When I go to the top right corner of YouTube.com, I can select "switch account"
Now when I click on it, the very first time I do it, it asks me to create a channel. If I do not do this step, the YouTube API will return a "no linked YouTube account" error. I confirm the change:
Now that I'm logged in, I should see this in the top corner of YouTube.com:
When I'm doing the OAuth 2.0 authorization flow, I'll be presented with a list of channels to authorize as:
You can test this out by going to the API reference and clicking on "Authorize Requests Using OAuth 2.0" under "Try it Now".
Rephrasing of the question:
Using the youtube api v 3.0 with oauth, when the user is sent to login, they have more than one option: e.g. the linked youtube account and the google account. The two different logins (access tokens) have different access to the api. I need the ability to just sent the user to log in to their proper youtube account (if they have one). How can my app do this? The user currently will have no idea which option they are supposed to choose, even if the app might be able to tell which they have chosen afterwards.
https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=1056190619576.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=https:%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube
original phrasing of the question:
OK, this is getting really really confusing. My youtube account uses a gmail, so I think that it is safe to say that it is linked to my google account (if such a thing linkage does exist). A couple of days ago I was on youtube, and the web site roped me into giving my youtube account its own google+ account (as far as I could tell). My gmail/google account does not have google+. Anyway, shortly thereafter I undid the linking of a google+ account to the channel. Ominously, at this point youtube indicated that this was only temporary.
And the net effect of this is: I can't use the youtube api with the youtube account. It says nolinkedyoutubeaccount .
So, the youtube api seems unusuable to me. This confusion is enough to make a person's head spin. But can anyone suggest a solution to get my account working with the api again?
Edit: I have managed to reproduce the error (more or less) with a newly opened youtube account. More here: https://code.google.com/p/gdata-issues/issues/detail?id=4860
These blog posts should help explain what's going on
http://apiblog.youtube.com/2013/06/google-page-identities-and-youtube-api.html
http://youtubecreator.blogspot.com/2013/04/using-google-page-identity-on-youtube.html
Based on what you describe, I think things are working as intended, but you do need to be careful to ensure that you select the correct channel when going through the OAuth 2 flow.