Giter VIP home page Giter VIP logo

Comments (7)

SpiGAndromeda avatar SpiGAndromeda commented on June 19, 2024 1

The repository methods to fetch data require a Context object. This object requires an AccessToken object and this is generated by using the AdminAuthenticator. That has to be triggered manually.

There is no automatic refresh. Shopware also doesn't provide a refresh token for every grant type. A client credentials authentication token e.g. doesn't contain one.

The AccescToken class has a isExpired method which can be used to check if a new token is required. If the token is expired an there is a refresh token, a RefreshTokenGrantType object can be created to reauthenticate. But this has to be done manually, too.

If the token used in the context object for the request is expired, Shopware will simply return 401 and the SDK will throw that as an exception.

from shopware-php-sdk.

gaxweb avatar gaxweb commented on June 19, 2024

Ok, it seems the reason is that, if you don't explicitly configure the AdminAuthenticator options to retry at least once, it won't do it at all and the 10 minute token will simply expire. That should be made more obvious IMHO.

Should have looked into the logs first. Error still occurring.

from shopware-php-sdk.

gaxweb avatar gaxweb commented on June 19, 2024

Can I please get an answer on this:

Does the client not make sure that the access token stays valid?

Do I have to refresh it myself? I can't find an error with the code. It works fine for about 10 Minutes (the default token time limit) and then it throws the error in the title.

from shopware-php-sdk.

vienthuong avatar vienthuong commented on June 19, 2024

@gaxweb

Do I have to refresh it myself? I can't find an error with the code. It works fine for about 10 Minutes (the default token time limit) and then it throws the error in the title.

With PasswordTypeGrantType, its by default alive for 10 minutes. You need to refresh the token afterward using RefreshTokenGrantType as hint from @SpiGAndromeda
If you want a longer duration access token, you can use ClientCredentialsGrantType instead

from shopware-php-sdk.

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.