Open BHuys opened 4 years ago
@BHuys got similar problem... this part of similar plugin preparation helped me: https://github.com/mkloubert/nativescript-social-login#setup-android-google-sign-in-for-debug-builds
I'm having the same issue. @RustamAkimov are you using a serverClientId with your request also?
I can get it to work when just passing only the clientId, but once I pass it the serverClientId the login attempts return {"provider":"google","code":1}
.
It works on iOS fine, but I can't get it to work with Android.
I got it resolved.
Turns out the OAuth 2.0 Client IDs I was using had a type of Other instead of Web Application. For whatever reason, the Android implementation of the Google Login will immediately reject using that server id, while the iOS version will not.
On Android you only need to use serverClientId and don't have to pass a clientId if you're using it to get an authCode.
It doesn't seem like specifying a certificate fingerprint is even necessary if you're doing server-side verification. @BHuys double check that the client ID you're using is the same one that is for your server, and also that it has the type Web Application.
I got it resolved.
Turns out the OAuth 2.0 Client IDs I was using had a type of Other instead of Web Application. For whatever reason, the Android implementation of the Google Login will immediately reject using that server id, while the iOS version will not.
On Android you only need to use serverClientId and don't have to pass a clientId if you're using it to get an authCode.
It doesn't seem like specifying a certificate fingerprint is even necessary if you're doing server-side verification. @BHuys double check that the client ID you're using is the same one that is for your server, and also that it has the type Web Application.
Can you PLEASE(X10) show me an example? i still can't make it work. i am trying this way:
GoogleLogin.init({
google: {
clientId: "",
serverClientId: "my_client_id_from_OAuth_android_credentials_i_created.apps.googleusercontent.com",
isRequestAuthCode: true
},
onActivityResult: undefined,
activity: application.android.foregroundActivity
})
i keep getting this result:
Cancelled
result. provider = google onActivityResult()
result. code = 1 onActivityResult()
Calling Callback function with Results
{
"provider": "google",
"code": 1
}
I tried using api of Android and of Web client but got the same result with both
Which platform(s) does your issue occur on?
Android
Info
I'm getting the popup where an account can be selected to show up, but when I tap on my account the loginprocedure gets 'cancelled'. Am I missing something?
code-snippets
//init GoogleLogin.init({ google: { initialize: true, serverClientId: xxxxx, clientId: xxxx, isRequestAuthCode: false }, activity: application.android.foregroundActivity });
//login button GoogleLogin.login(result=>{ console.dir(result); });
logs
JS: 'Starting activity for result...' JS: 'Cancelled' JS: 'result. provider = google' 'onActivityResult()' JS: 'result. code = 1' 'onActivityResult()' JS: 'Calling Callback function with Results' JS: ==== object dump start ==== JS: provider: "google" JS: code: "1" JS: ==== object dump end ====
hi, i am having the exact same problem. Did you find any solution?
@odedBartov Are testing in production build?
@odedBartov Are testing in production build?
No, why?
In the Google Console you have to insert your keystore Sha-1 string, if you test your app in a production build using the keystore the google login will work
In the Google Console you have to insert your keystore Sha-1 string, if you test your app in a production build using the keystore the google login will work
I am not sure i understand you. What is the actuall difference between release build and debug build? I did insert the Sha-1 string in the google console. Anyway, i built the app with the keystore but still bumped into the same problem... it didn't solved it
Do you hace your init function like this for android?
GoogleLogin.init({
google: {
initialize: true,
isRequestAuthCode: true,
clientId: google_login.android,
serverClientId: google_login.server_client_id
},
viewController: Application.android.foregroundActivity
});
Do you hace your init function like this for android?
GoogleLogin.init({ google: { initialize: true, isRequestAuthCode: true, clientId: google_login.android, serverClientId: google_login.server_client_id }, viewController: Application.android.foregroundActivity });
Yes, exept the clientId which i left empty
Try including the clientID from the Google Console, Android OAuth Key
I already did, same result
Hello, we have the same issue even with a production app. Any news? Thanks
I had the same issue
Here's the solution
Web Application
- Do not create for Android
That's it
Thanks @shahen94, I tried your config without any luck. In the Google Developer Console I had both Android ID and Server ID so I deleted the Android ID I also generated a new Web Application ID but it didn't work
Any idea?
Thanks
@mrzanirato can you please try to remove app and install again?
I tried but nothing ... here is my console log
JS: Will request ID token JS: Google Login JS: Starting activity for result... JS: Cancelled JS: result. provider = google onActivityResult() JS: result. code = 1 onActivityResult() JS: Calling Callback function with Results JS: Error: Unexpected HTTP status code (404)
Just to be sure I also tried building a release apk ... same problem
@shahen94 do you have a working example app to test? Thanks
Hello @shahen94 can you confirm that the code is actually working in Android? Thanks
@pboulch can you please check if the plugin is still working in Android? Thanks
I had the same issue
Here's the solution
- Open Google Developer Console
- Create Credentials for
Web Application
- Do not create forAndroid
- Copy client id
- in the init function use the following code
That's it
@mrzanirato I managed to fix the problem following @shahen94 comment, I deleted the clientId
field, and wait a bit (like 10 min) for the Web Application serverClientId
to be ready on Google Console.
Which platform(s) does your issue occur on?
Android
Info
I'm getting the popup where an account can be selected to show up, but when I tap on my account the loginprocedure gets 'cancelled'. Am I missing something?
code-snippets
//init GoogleLogin.init({ google: { initialize: true, serverClientId: xxxxx, clientId: xxxx, isRequestAuthCode: false }, activity: application.android.foregroundActivity });
//login button GoogleLogin.login(result=>{ console.dir(result); });
logs
JS: 'Starting activity for result...' JS: 'Cancelled' JS: 'result. provider = google' 'onActivityResult()' JS: 'result. code = 1' 'onActivityResult()' JS: 'Calling Callback function with Results' JS: ==== object dump start ==== JS: provider: "google" JS: code: "1" JS: ==== object dump end ====