Code Monkey home page Code Monkey logo

Comments (14)

OurDream200799 avatar OurDream200799 commented on July 16, 2024 1

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??

from nativescript-google-login.

captainhaddockfr35 avatar captainhaddockfr35 commented on July 16, 2024

Hi,
Could you share a github project with your error ? And did you give the clientId and the serverClientId at initialization ?
Thanks

from nativescript-google-login.

zeleee avatar zeleee commented on July 16, 2024

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

from nativescript-google-login.

captainhaddockfr35 avatar captainhaddockfr35 commented on July 16, 2024

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

from nativescript-google-login.

zeleee avatar zeleee commented on July 16, 2024

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.

from nativescript-google-login.

captainhaddockfr35 avatar captainhaddockfr35 commented on July 16, 2024

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;
}

from nativescript-google-login.

zeleee avatar zeleee commented on July 16, 2024

Ok, but the problem with undefined result still exist in android.

from nativescript-google-login.

captainhaddockfr35 avatar captainhaddockfr35 commented on July 16, 2024

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 ?

from nativescript-google-login.

zeleee avatar zeleee commented on July 16, 2024

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.
image

With that clientId i am still getting result.userToken to be undefined.

from nativescript-google-login.

captainhaddockfr35 avatar captainhaddockfr35 commented on July 16, 2024

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 ?

from nativescript-google-login.

zeleee avatar zeleee commented on July 16, 2024

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.

from nativescript-google-login.

captainhaddockfr35 avatar captainhaddockfr35 commented on July 16, 2024

Are you sure this is the right keystore ? You don't use a default debug.keystore file to sign your dev applications ?

from nativescript-google-login.

cobreen avatar cobreen commented on July 16, 2024

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"

from nativescript-google-login.

odedBartov avatar odedBartov commented on July 16, 2024

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?

from nativescript-google-login.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.