mkloubert / nativescript-social-login

NativeScript plugin for social (token based) log-ins.
MIT License
42 stars 44 forks source link

ERROR TypeError: Cannot read property 'GoogleSignInOptions' of undefined #37

Closed ntaylor2 closed 6 years ago

ntaylor2 commented 6 years ago

Hi, I'm working on a Nativescript (Angular) project using the nativescript-social-login plugin for simple Google authentication on android. Currently running NS 3.4.2 and social-login 3.0.8.

I have walked through the setup steps on your getting started page, but am getting the following error when calling SocialLogin.loginWithGoogle

ERROR TypeError: Cannot read property 'GoogleSignInOptions' of undefined

Any idea what could be causing this issue? I have code in my main.ts file to init nativescript-social-login as follows:

if (application.android) {
    application.android.on(application.AndroidApplication.activityResumedEvent, () => {
        let result = SocialLogin.init({
            google: {
                initialize: true,
                serverClientId: '{my_server_client_id}'
            },
            facebook: {
                initialize: false
            }
        });
    });

    SocialLogin.addLogger(function (msg: any, tag: string) {
        console.log('[nativescript-social-login]: (' + tag + '): ' + msg);
    });
}

Here is my code to call login after clicking a button in the app:

login(event) {
        console.log("Attempting to login");
        SocialLogin.loginWithGoogle((result) => {
            this.ngZone.run(() => {
                console.log("code: " + result.code);
                console.log("error: " + result.error);
                console.log("userToken: " + result.userToken);
                console.log("displayName: " + result.displayName);
                console.log("photo: " + result.photo);
                console.log("authToken: " + result.authToken);
                if (result.error || result.code == SocialLogin.LoginResultType.Cancelled) {
                    this.loginFailedState = 'visible';
                } else {
                    this.navigateToLabList();
                }
            });
        });
    }

Any help would be greatly appreciated. Let me know if you require more information.

jogboms commented 6 years ago

@ntaylor2 Do you mean your codebase doesn't have any reference to GoogleSignInOptions?

ntaylor2 commented 6 years ago

Yes, it appears that's the case. When debugging I can see that com.google.android.gms.auth.api package is defined but the com.google.android.gms.auth.api.signin package is not.

jogboms commented 6 years ago

@ntaylor2 I really don't follow. Could you confirm if this issue persists using the demo app? or can you create a repo reproducing the same issue?

ntaylor2 commented 6 years ago

@jogboms I'm closing this issue. When I started building a sample app to show you the issue, it magically started working. I love it when that happens :)