Support access token
ionutcalara opened this issue · 10 comments
Hi there,
I found the OAuth refresh token scenario where I can authenticate with that, but I couldn't find any way to bypass that in case I stored the access token. Is this possible?
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.
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.
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.
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?
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?
@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 apisupport@gettyimages.com
? 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.
@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.
Thanks for your help and patience, @ionutcalara! I've merged your PR and the new package (v4.1.0) is now available on Packagist.
Thank you for your patience and for merging!