Coder Social home page Coder Social logo

Comments (4)

tsuyoshizawa avatar tsuyoshizawa commented on August 31, 2024 1

If AccessToken has to be reissued upon each request, what's the use of methods such as getStoredAccessToken or even the logic to refresh it?

We expect that getStoredAccessToken is used for cache on your datastore.

I assumed that created AccessToken remains valid and is returned for all requests until it expires, so there is no need to reissue it until then.

So you can return cached access token from datastore until access token expires by getStoredAccessToken. You just return None on the method if you want to create new access token everytime.

I don't see how expiresIn can evaluate to false. It is eagerly evaluated in AccessToken constructor when createAccessToken is called,

By saving and getting the access token created time in the datastore, you should be able to specify lifeSeconds and take expiresIn to false.

I made a sample code before. I hope it help you. https://github.com/tsuyoshizawa/scala-oauth2-provider-example-skinny-orm/blob/master/app/controllers/OAuthController.scala

from scala-oauth2-provider.

tsuyoshizawa avatar tsuyoshizawa commented on August 31, 2024

We expect that AccessToken use only one instance for one request coming.

The access token is created when user authorize via OAuth server first.
With the created access token, expiresIn is evaluated when calling the API in a request, so that AccessToken#isExpired can call true.

from scala-oauth2-provider.

nebehr avatar nebehr commented on August 31, 2024

If AccessToken has to be reissued upon each request, what's the use of methods such as getStoredAccessToken or even the logic to refresh it? Just send a new request and get a new token every time.

My understanding was different. I assumed that created AccessToken remains valid and is returned for all requests until it expires, so there is no need to reissue it until then.

Also, I don't see how expiresIn can evaluate to false. It is eagerly evaluated in AccessToken constructor when createAccessToken is called, and the only way it can be expired at the same moment is if you provide a negative lifeSeconds which is not a valid use case anyway.

from scala-oauth2-provider.

nebehr avatar nebehr commented on August 31, 2024

you can return cached access token

But when you return this cached access token, it will have expiresIn from the time it was first calculated, i.e. when it was created! That was my point. When I retrieve access token from cache, I expect to see actual time until expiration.

from scala-oauth2-provider.

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.