Skip to content

Commit

Permalink
Fixed auth response for google login provider abacritt#365
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooja Bhor authored and Pooja Bhor committed Feb 16, 2021
1 parent 917645e commit 5c33a01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions projects/lib/src/entities/social-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class SocialUser {

idToken: string; // Reference https://developers.google.com/identity/sign-in/web/backend-auth
authorizationCode: string; // Reference https://developers.google.com/identity/sign-in/web/reference#googleauthgrantofflineaccessoptions
authResponse: any; // get complete authResponse object

response: any;
}
4 changes: 4 additions & 0 deletions projects/lib/src/providers/google-login-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ export class GoogleLoginProvider extends BaseLoginProvider {
let user: SocialUser = new SocialUser();

const profile = this.auth2.currentUser.get().getBasicProfile();
const authResponse = this.auth2.currentUser.get().getAuthResponse(); // get complete authResponse object
user.id = profile.getId();
user.name = profile.getName();
user.email = profile.getEmail();
user.photoUrl = profile.getImageUrl();
user.firstName = profile.getGivenName();
user.lastName = profile.getFamilyName();
user.response = profile;
user.authResponse = authResponse;

const resolveUser = authResponse => {
user.authToken = authResponse.access_token;
Expand Down Expand Up @@ -104,6 +106,7 @@ export class GoogleLoginProvider extends BaseLoginProvider {
let backendToken = this.auth2.currentUser
.get()
.getAuthResponse(true).id_token;
const authResponse = this.auth2.currentUser.get().getAuthResponse();

user.id = profile.getId();
user.name = profile.getName();
Expand All @@ -113,6 +116,7 @@ export class GoogleLoginProvider extends BaseLoginProvider {
user.lastName = profile.getFamilyName();
user.authToken = token;
user.idToken = backendToken;
user.authResponse = authResponse;

user.response = profile;
}
Expand Down

0 comments on commit 5c33a01

Please sign in to comment.