Git Product home page Git Product logo

Comments (10)

mapitman avatar mapitman commented on September 15, 2024

If you'd like to use the refresh token that you've stored from another session, there is a method on the GettyImages_Client

https://github.com/gettyimages/gettyimages-api_php/blob/master/src/GettyImages_Client.php#L144

So it would look something like this:

$client = GettyImages_Client::getClientWithClientCredentials("API_KEY", "API_SECRET", "REFRESH_TOKEN");

I'm going to close this, but feel free to re-open if this doesn't answer your question.

from gettyimages-api_php.

ionutcalara avatar ionutcalara commented on September 15, 2024

Hi @mapitman I was talking about auth with access_token not with the refresh_token. Currently with the refresh token, for every session, the SDK will make a call that will fetch the access_token. That can be avoided for 30 minutes since the access_token is valid.

I am not able to reopen.

from gettyimages-api_php.

mapitman avatar mapitman commented on September 15, 2024

The GettyImages_Client class is meant to be used as a singleton across the lifetime of your application which will allow it to handle token renewal for you.

if you are talking about storing the access token and re-using it between starts/stops of your application, the SDK does not currently support that. We'd be open to accepting a pull request though.

from gettyimages-api_php.

ionutcalara avatar ionutcalara commented on September 15, 2024

Hi @mapitman I was able to create the pull request #11 . Let me know if you need me to do anything or it can be merged.

from gettyimages-api_php.

ChrisSimmons avatar ChrisSimmons commented on September 15, 2024

Hello @ionutcalara ! Would you be able to use the GettyImages_Client as a singleton as @mapitman mentioned above? Or does that impose a burden on the work you are doing?

from gettyimages-api_php.

ionutcalara avatar ionutcalara commented on September 15, 2024

Hi @ChrisSimmons the pull request doesn't affect the singleton principle. I want to initialize with an access token when I have it, instead of getting one via the API. In my case, this speeds up subsequent search queries since the access token has a 30 minutes expiration period.

Does that make sense?

from gettyimages-api_php.

ChrisSimmons avatar ChrisSimmons commented on September 15, 2024

@ionutcalara I marked my approval on the PR. I'd like to get another Getty dev's ✔️ on it first though before merging.

In the meantime would you mind making contact with [email protected]? We'd like to understand how you are using the API and perhaps help out. I'm going under the assumption here that you are using resource owner authentication with numerous user accounts, hence the difficulty in keeping singleton clients per-user.

from gettyimages-api_php.

ionutcalara avatar ionutcalara commented on September 15, 2024

@ChrisSimmons thanks for the fast reply, I was out of the office for a few days. I have already received support for my use case from the team, I got approval and the integration is live already. Thanks for offering.
My users consume the api with their own accounts. I realized I could have stored the entire client objects and reuse them, but that would have been more complicated and harder to maintain.

If you have any questions or requests, let me know.

from gettyimages-api_php.

ChrisSimmons avatar ChrisSimmons commented on September 15, 2024

Thanks for your help and patience, @ionutcalara! I've merged your PR and the new package (v4.1.0) is now available on Packagist.

from gettyimages-api_php.

ionutcalara avatar ionutcalara commented on September 15, 2024

Thank you for your patience and for merging!

from gettyimages-api_php.

Related Issues (5)

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.