Issues of Social Login

2.1k Views Asked by At

I'm able to login, log out and "Remove account" with Gmail in standalone Chrome same as ordinary non-developer end users.

Start a skeleton Angular project in VSC using angularx-social-login, encounter the following two issues with login.

Issue 1) F5 with typical launch setting, after username and password got a message below (regardless logoutWithGoogle is triggered.)

{
    "type": "pwa-chrome",
    "request": "launch",
    "name": "F5 against localhost",
    "url": "http://localhost:4200",
    "webRoot": "${workspaceFolder}"
}

Couldn't sign you in This browser or app may not be secure Try using a different browser. ...

enter image description here

Issue 2) Using attach process for debugging, it bypasses username/password and let me in after following screen shows briefly (regardless logoutWithGoogle is triggered)

{
    "name": "Attach to a running Chrome @4200",
    "type": "pwa-chrome",
    "request": "attach",
    "port": 9222,
    "urlFilter": "http://localhost:4200/*",
    "webRoot": "${workspaceFolder}"
},

enter image description here

app.modules.ts

import { GoogleLoginProvider, SocialAuthServiceConfig, SocialLoginModule } from 'angularx-social-login';
@ngModule({ ...
  providers: [ {provide: 'SocialAuthServiceConfig', useValue:{autoLogin: false, providers: [{id: GoogleLoginProvider.PROVIDER_ID, provider: new GoogleLoginProvider('my Google-Client-ID')}]} as SocialAuthServiceConfig,}, ] 

app.component.ts

import { SocialAuthService, GoogleLoginProvider, SocialUser } from 'angularx-social-login';
...
constructor(private socialAuthService: SocialAuthService) {}
ngOnInit()
{
this.socialAuthService.authState.subscribe
    (
        user => 
        {
            this.socialUser = user;
            this.isLoggedin = (user != null);
            console.log(this.socialUser);
        },
        bad => 
        {
            console.log(bad);
        }
    );
}
loginWithGoogle(): void { this.socialAuthService.signIn(GoogleLoginProvider.PROVIDER_ID);}
logoutWithGoogle(): void { this.isLoggedin = false; this.socialAuthService.signOut(); }

Since standalone Chrome works perfectly, it should be related to Angular package or VSC. Here are the versions listed in cmd window:

[email protected]
Angular CLI: 11.2.6
Node: 14.9.0
OS: win32 x64

Angular: 11.2.7
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1102.6
@angular-devkit/build-angular   0.1102.6
@angular-devkit/core            11.2.6
@angular-devkit/schematics      11.2.6
@angular/cli                    11.2.6
@schematics/angular             11.2.6
@schematics/update              0.1102.6
rxjs                            6.6.6
typescript                      4.0.7

VSC About:

Version: 1.56.2 (user setup)
Commit: 054a9295330880ed74ceaedda236253b4f39a335
Date: 2021-05-12T17:13:13.157Z
Electron: 12.0.4
Chrome: 89.0.4389.114
Node.js: 14.16.0
V8: 8.9.255.24-electron.0
OS: Windows_NT x64 10.0.19041
2

There are 2 best solutions below

0
Jeb50 On BEST ANSWER

The solution for F5 debugging is to change settings of launch.json:

  1. use legacy "chrome" instead of pwa-chrome for type.
  2. use a diff port than the default 4200 or whatever your project is using, as long this new port is available. For example 4201 for my Angular.

Following is mine:

{
    "type": "chrome",
    "request": "launch",
    "name": "F5 against localhost",
    "port": 4201,
    "url": "http://localhost:4200",
    "webRoot": "${workspaceFolder}"
}
1
Aakash Garg On

This problem isn't specific to VSC debug mode. It happens whenever you try to sign in to Google in a Chrome instance that has debugging turned on. In other words, if you, your automation software, or IDE starts up chrome with a command like chrome.exe --remote-debugging-port=9222.

In both attach and launch mode the vsc attaches a remote port to control the browser.

A same issue raised at chromium issues :- https://bugs.chromium.org/p/chromium/issues/detail?id=1173641

https://github.com/microsoft/vscode-js-debug/issues/918#issuecomment-771928066

To check in your google account security settings you can choose to allow less secure applications to access your account for debugging purpose.

https://support.google.com/accounts/answer/6010255?hl=en#zippy=%2Cif-less-secure-app-access-is-on-for-your-account