Giter Site home page Giter Site logo

Comments (5)

rubenCodeforges avatar rubenCodeforges commented on June 14, 2024

@AngelLuisSanchez hi , i think you just need to refresh the token.

If you are calling a signIn method , it should return you a Promise<GoogleUser> .
now if we check this type https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/gapi.auth2/index.d.ts#L232

You can see it has a method reloadAuthResponse() which should refresh your token

from ng-gapi.

AngelLuisSanchez avatar AngelLuisSanchez commented on June 14, 2024

Ok, I'll try... but, another question in order to manage session, when I entry in the app and do login.

What's up with object GoogleUser?

public setUser(user: GoogleUser): void {
   this.user = user;
 }

 public getCurrentUser(): GoogleUser {
   return this.user;
 }

In the library and your examples, you have this two methods, when I set the value of the object GoogleUser?
I suppose it will be when I do login... but I don't have Google User object in response :/

private signInSuccessHandler(res: GoogleUser) {
    this.ngZone.run(() => {
      sessionStorage.setItem(UserService.SESSION_STORAGE_KEY,res.getAuthResponse().access_token);
    });
  }

from ng-gapi.

rubenCodeforges avatar rubenCodeforges commented on June 14, 2024

Im not getting your question ?

Im just trying to guess what you are trying to do , i assume you want to keep track of your 403 requests and do a refresh of the token.

Perhaps this articles will help you out:

  1. Angular interceptors https://medium.com/@ryanchenkie_40935/angular-authentication-using-the-http-client-and-http-interceptors-2f9d1540eb8
  2. Gapi FAQ Refresh token https://developers.google.com/api-client-library/javascript/help/faq#how-do-i-refresh-the-auth-token-and-how-often-should-i-do--------it

from ng-gapi.

rubenCodeforges avatar rubenCodeforges commented on June 14, 2024

Oh and my examples are just general examples , they should not be taken as solutions , each app is differently

from ng-gapi.

AngelLuisSanchez avatar AngelLuisSanchez commented on June 14, 2024

Sorry for my poor explanation...

I got it with handler error in the subscribe.

this._apiService.METHOD(this._userService.getToken())
      .subscribe(
        resp => {
        },
        error => {
          // SERVICE THAT HANDLER ERROR (such as token expired)
          this._handlerErrorService.handlerError(error);
        }
      );
  }

Thanks a lot for your response!

from ng-gapi.

Related Issues (20)

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.