abacritt / angularx-social-login

Social login and authentication module for Angular 17
630 stars 388 forks source link

TypeError: Cannot read properties of null (reading 'id') when tried to get refreshToken after page reloads #679

Closed fawadmukhtar closed 9 months ago

fawadmukhtar commented 1 year ago
  1. Logged in with google sign in button.
  2. everything works fine,
  3. without reloading the page I can get refreshToken as expected.
  4. Issues come out when I reload the page. and try to get refreshToken. that returns the below error.

image

core.mjs:9171 ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of null (reading 'id') TypeError: Cannot read properties of null (reading 'id') at abacritt-angularx-social-login.mjs:105:62 at new ZoneAwarePromise (zone.js:1429:21) at GoogleLoginProvider.refreshToken (abacritt-angularx-social-login.mjs:104:16) at abacritt-angularx-social-login.mjs:295:30 at new ZoneAwarePromise (zone.js:1429:21) at SocialAuthService.refreshAuthToken (abacritt-angularx-social-login.mjs:283:16) at UserTasksComponent.refreshToken (user-tasks.component.ts:89:30) at UserTasksComponent_ng_template_2_Template_button_click_0_listener (user-tasks.component.html:8:51) at executeListenerWithErrorHandling (core.mjs:15679:16) at wrapListenerIn_markDirtyAndPreventDefault (core.mjs:15714:22) at resolvePromise (zone.js:1211:31) at zone.js:1118:17 at zone.js:1134:33 at abacritt-angularx-social-login.mjs:301:29 at _ZoneDelegate.invoke (zone.js:372:26) at Object.onInvoke (core.mjs:26274:33) at _ZoneDelegate.invoke (zone.js:371:52) at Zone.run (zone.js:134:43) at zone.js:1275:36 at _ZoneDelegate.invokeTask (zone.js:406:31)

**Expected Behavior**
it shouldn't return this error. and emit SocialUser to authState observable. 

**My Versions:**
 "@abacritt/angularx-social-login": "^1.3.2",
 "@angular-devkit/build-angular": "^14.2.10",
Mxa30 commented 1 year ago

I'm having the same issue. I expect the login to persist after reload but that doesn't seem to be the case. I tried fixing it by setting using the refreshAuthToken but now I get this same error.

Code inside constructor:

this.authService.initState.subscribe(() => {
      this.authService.refreshAuthToken(GoogleLoginProvider.PROVIDER_ID);
})
HoudaAdd commented 1 year ago

Same problem here :/ any fixes ??

ErickVal commented 1 year ago

Same.

HoudaAdd commented 1 year ago

Any news about this ?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.