Open zeleee opened 4 years ago
Hi, Could you share a github project with your error ? And did you give the clientId and the serverClientId at initialization ? Thanks
I cant share this project, but I can answer any question. Yes, I have put serverClientId, and clientId in the initialization, but since I don't have third party service for auth, I have used Id provided by google (so both client id and server client id have full id like this 1098248567151-xxxxxxxxx.apps.googleusercontent.com).
since I cant run your angular demo (button is not working), I can make a POC, if the problem persists I can share that code here
Without and example to test, it's hard to give a solution. If you don't have third party service, you can set isRequestedAuthCode
to false
https://github.com/zeleee/google-login-POC
Here is the proof of concept, The error is not one described above (the error is caused by undefined results from the google services) Now my next question is how can i get data from the result google services gave us (for instance userToken, id, etc.)
I also edited the title just for anyone who has this problem could find it.
Hi,
For iOS, you must add config into Info.plist
:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.googleusercontent.apps.yourid</string>
<!-- It shoud look like this: com.googleusercontent.apps.123123123-172648sdfsd76f8s7d6f8sd -->
<!-- Get it from your GoogleService-Info.plist -->
<!-- Read more - https://developers.google.com/identity/sign-in/ios/start-integrating -->
</array>
</dict>
</array>
and the controller must be initialized (so the init must be done into the Delegate) :
if(isIOS){
class MyDelegate extends UIResponder implements UIApplicationDelegate {
public static ObjCProtocols = [UIApplicationDelegate];
applicationDidFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary<string, any>): boolean {
console.log("applicationWillFinishLaunchingWithOptions: " + launchOptions)
return true;
}
applicationDidBecomeActive(application: UIApplication): void {
console.log(app.ios.rootController);
GoogleLogin.init({
google: {
initialize: true,
serverClientId: "<your_server_client_id>",
clientId: "<your_client_id>",
isRequestAuthCode: false
},
viewController: app.ios.rootController
});
}
}
ios.delegate = MyDelegate;
}
Ok, but the problem with undefined result still exist in android.
Maybe it's a configuration problem with your Google ids, I don't have any problem with my ids. Did you register your application with its ID and sha1 on the Google console ?
yes, I followed the procedure with oauth2 clientID, I ran keytool -keystore /path/ -list -v, copied sha1 and pasted it in google console, inserted package name from xml, and created client id
Then I inserted that key into clientId and serverClientId field in android configuration inside login.ts
Here is the image.
With that clientId i am still getting result.userToken to be undefined.
Hi, I think it's a configuration with your Google ids. I tried your POC with my Google keys and it works, I got a result with the account information. Did you give the SHA1 of your debug keystore ? Did you give the correct application id between the Google interface and the package.json ?
yes, here is my proces. I went to the google console, and clicked to credentials. I selected create credentials and selected oauth client id I inserted a name of my application, and then went to the cmd and typed keytool -keystore ~/users/admin/.android -list -v, then i entered the password, and copied SHA1 I copied package name from AndroidManifest.xml in android resources. then i copied ClientId from google console, and pasted it in the login.ts under serverclientId and clientId.
Are you sure this is the right keystore ? You don't use a default debug.keystore
file to sign your dev applications ?
HI i m tring to setup google login Error Getting--> JS: activity: undefined
and i m confunse between clientid and serverClientId,
is this clientid and secret??
Should I build a release version in order to make it work? This is the command I use to test. tns run android --release --key-store-path="C:\Users\path\key.jks" --key-store-password="Password" --key-store-alias="key0" --key-store-alias-password="Password"
https://github.com/zeleee/google-login-POC
Here is the proof of concept, The error is not one described above (the error is caused by undefined results from the google services) Now my next question is how can i get data from the result google services gave us (for instance userToken, id, etc.)
I also edited the title just for anyone who has this problem could find it.
i am using your POC with my ID but i gets no result. "Starting activity for result..." is printed to the console and i can log into my google account, but after i do nothing happend. any help PLEASE?
Hi, I am having some troubles with setting up google login on my angular app. This is the error I get when I push the log in button. The setup process is not that complicated, so I don't know what am I doing wrong. I tried running the app in the Android 9, and below you can see the error I get, login.ts and AndroidManifest.xml. Also, I am not using a service, so for this part of developement i want to make it simple (just nativescript app to google login if that is possible).