How to use authclient async to use those credentials in the future?

Sincerely I don’t know how to explain this in proper english.

authclient is working perfectly as login into a system, but I need to use it with other purposes, like “google calendar sync” or “posting in a Twitter account” after the login, in the future … so I need access_token to do the calls.

After the user has “connected” his account, I can immediately use the “client” object to do some calls.

But after 10 days passed, the access_token expires (in most of services) and I don’t know how to get the client again to use it (it does not store in the database the access_token o even the refresh_token in order to “refresh” the auth)

Thank you

Likely you need to exchange regular token to “long-lived” or “non-expiring” token. Methods are different for each API. For example, for Twitter tokens are non-expiring: https://developer.twitter.com/en/docs/basics/authentication/faq

Thank you for that information … :wink:
But the problem is the same … My question is specifically : how can I retrieve the “client” object in order to use it for doing something with it.

My problem right now is that when I get (for example):
$client = Yii::$app->authClientCollection->getClient(‘google_calendar’);
it crashes … it needs to refresh the token, but I don’t know how.

Do you have ANY platform or provider with a refresh_token coded, in order to see how to duplicate in other providers as well ?

THANK YOU

No. Personally I’m using auth package for authentication only.

Does anyone has use this for this case?
I can’t believe it there’ no way to use authclient for use the token in the future (in a cron job for example)

It would be nice to save the “access_token” (or the whole Token object) in order to use it for future uses.