Search code examples
androidyoutubegoogle-oauth

Connect to Youtube account using Google Sign-In Android SDK


based on what Google announced in this blog post we're in the process of migrating our old webview-based connection flow to the Google Sign-In SDK. Our need is to allow our users to connect their youtube account to our app, so we were starting a web-based authentication flow with adding the Youtube scopes, and the flow also managed automatically the channel selection, in case the user have more than one.

While on iOS the Google Sign-In SDK still use a web-based authentication flow (and it works like a charm with the channel selection) on Android the whole process is native and managed by Play Services. Unfortunately it looks like it doesn't support the channel selection and it automatically fallback to the default channel.

We also tried to migrate to Chrome Custom tabs, but it looks like you're not be able to "intercept" which url is loading, and so we can't detect while the process completes and extract the authentication code.

Anyone had the same issue? Any ideas?

Thanks!


Solution

  • The Play Services library doesn't support channel selection.

    Chrome Custom Tabs can definitely work the way you need (and then it will be exactly like on iOS). Try the AppAuth for Android library (an open source library that was was created by Google).

    You will use a custom URI scheme for the redirect URI, much like on iOS.

    The interactive codelab is very helpful, you can apply the steps to your own apps.