2

I'm trying to create a playlist on YouTube using the YouTube Data API v3 via and Android app. When I have a Google Account that is linked to YouTube everything works fine. However, if I have a Google Account that is unlinked then I get the following response

com.google.api.client.googleapis.json.GoogleJsonResponseException: 401 Unauthorized { "code": 401, "errors": [ { "domain": "youtube.header", "location": "Authorization", "locationType": "header", "message": "Unauthorized", "reason": "youtubeSignupRequired" } ], "message": "Unauthorized" }

Is there a way to fix this issue through the API itself, or is there an Intent I can launch on Android to solve this issue?

If I go to the YouTube website directly, when I try to create a playlist there I'm presented with this dialog to create a linked account also.

enter image description here

Are these 2 solutions from 2013 still the only way to achieve my outcome?

https://stackoverflow.com/a/14492382/2205809

https://stackoverflow.com/a/16024919/2205809

The second one seems quite brittle in that I have to check for a web flow for a specific URL, if Google ever changed that it'd break my app.

Andrew Kelly
  • 2,180
  • 2
  • 19
  • 27
  • One downside to using the webview approach is that even though I've chosen an account using the Account Chooser on Android, when I present the webview, the user has to authenticate again. Its not the most frictionless path to success, and since users will only ever see this on their first use of the feature, I imagine the drop off rate could be quite high. – Andrew Kelly Apr 04 '19 at 12:10

2 Answers2

0

There is no intent to deal with the exception per say; What I did was bring up an activity that allows the user to open the youtube app if it is installed [and install it if it is not] From there the user can link the account, and on my case create a channel. I can get you some code if you want when I get to the pc...its really just an intent with a link to the you tube app.

  • At the moment, I'm going for the WebView approach as mentioned in the 2nd SO link I posted. It seems to be the offical way still according to the docs online, an Intent would be nice. Or even better a way to just create a channel via the API for a given user account. – Andrew Kelly Apr 04 '19 at 04:50
  • I agree it would be nice since you know they don't have a channel – keepTrackOfYourStack Apr 04 '19 at 14:01
0

Having spoken with a Googler, the answer provided in the 2nd link of my question is still the valid in 2019.

They recommend to launch a webview and get the user to complete the sign-up process there.

Instructions can be found here.

https://developers.google.com/youtube/create-channel

Andrew Kelly
  • 2,180
  • 2
  • 19
  • 27