Weble / ZohoClient

11 stars 7 forks source link

getAccessToken and getRefreshToken both uses the grant_code when calling it for the first time #20

Closed jvandervalk closed 3 years ago

jvandervalk commented 3 years ago

If you're using offline mode and want to retrieve/save the acces_tokens and refresh_tokens for the first time you will get an invalid_code error when you call both getAccessToken() and getRefreshToken().

This is because both functions will try to fetch the tokens by using the underlying generateTokensFromGrantToken() method if you call getAccessToken() first and getRefreshToken() second, as said in de readme. A solution is to use getRefreshToken() first, so in the getAccessToken() method the refresh_token is used.

Not sure if you want to change the underlying code or just update the readme.

Skullbock commented 3 years ago

Thanks for the notice, i've updated the readme. If you feel like sending a PR to cover this use case, feel free to do so!