Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google OAuth Client with Angular/Ionic: How do I find the redirect_uri?

I have an Ionic2 app that I would like to add GooglePlus Authentication to.

I get the following error:

enter image description here

As far as I understand, it's because I have not set up a redirect_uri.

Question

What redirect_uri (Authorized redirect URIs) should I use for an Ionic2 app? Where do I find it?

enter image description here

The following works with Facebook login.

enter image description here

UPDATE

Following these instructions, I changed the REVERSED_CLIENT_ID to the following format:

"com.googleusercontent.apps.uniqueId"

So I think I have made progress.

I now get the following error in iOS:

enter image description here

From reading here, this means that the credentials should not be created for a Web Application here. But if I create it for iOS, how will this work for Android? Or does Android not make use of these credentials anyway?

For Android, when I try to log in, I just get an exception with an undefined error message.

So I have two questions please:

  1. Do I need to create iOS client ID here instead of a Web application?

enter image description here

  1. How do I configure or debug this for Android?

UPDATE

For iOS I added an iOS Client Id and changed my REVERSED CLIENT ID to match, and like with Android, it prompted me to sign into my Google Account. So that looks like further progress.

However, once I sign in, like with Android now I get an exception with the message as undefined. In the Xcode console, however, I do get the following:

com.google.HTTPStatus error 400.

Following these, I have now created credentials for both iOS and Android.

enter image description here

I have configured Android and iOS IDs in the new IDs.

I get an exception with the message as undefined on both Android and iOS.

UPDATE

Got it working for iOS. The webClientId option when you call login must not be the reversed client id, but rather the client id.

        GooglePlus.login({
            'webClientId': 'xxxxx.apps.googleusercontent.com',
            'offline': true
        }).then(googleData => {

Now to figure out why Android doesn't work.

In Android, I now get error = 12501 (which is a result of something wrong with my Keystore I think).

UPDATE

I generate the Keystore. As per these instructions, I copy the SHA1 to the Signing-certificate fingerprint. But still get error = 12501.

enter image description here

like image 553
Richard Avatar asked Mar 08 '17 06:03

Richard


1 Answers

As you got iOS working, here is solution for Android.

Build APK of your app and then run this command-

keytool -list -printcert -jarfile app.apk

The output will reveal the Signature, Certificate fingerprints (MD5, SHA1 and SHA256) and Extensions of the APK.

Copy the SHA1 to the Signing-certificate fingerprint while creating client ID for android

like image 139
Swapnil Patwa Avatar answered Oct 23 '22 13:10

Swapnil Patwa