Closed Jammizzle closed 3 years ago
Of course as soon as I create the ticket, my next run works... how odd
I'll leave this here in case there is something blaringly wrong with the above implementation, if there isn't then feel free to close away :)
Yeah, I'm not sure what coulda happened. Sorta, kinda sounds like somehow Postman had something to do with it.
If at some point you create new id/secret on zoho, and have a similar issue, please report it. I feel like I had a similar weirdness back when I was starting this project.
There might be a stupid statement in the GenerateTokenRequest
function. It checks for a saved token, and
func (z *Zoho) GenerateTokenRequest(clientID, clientSecret, code, redirectURI string) (err error) {
z.oauth.clientID = clientID
z.oauth.clientSecret = clientSecret
z.oauth.redirectURI = redirectURI
err = z.CheckForSavedTokens()
if err == ErrTokenExpired {
return z.RefreshTokenRequest()
}
I'm forgetting how this should work.
It checks for a saved tokens file, if the token is expired (what does a 0 value Expiry or empty file return in CheckExpiry()??) we try to refresh the token instead of generating a new one, and simply return the result of the refresh call. The refresh call uses q.Set("grant_type", "refresh_token")
and returns an error.
if tokenResponse.Error == "invalid_code" {
return ErrTokenInvalidCode
}
If you experience this issue again, this is the first place I'd look.
I've failed at the first hurdle it seems!
I'm trying to create an access and request token using the below, but I'm getting hit with the default "invalid_code" error:
I had a look at the url copying the same method you do before the POST with:
If I take the output from the logging.Info() line and paste it into postman, I get a successful response back with the auth and refresh token, but the code fails for "invalid_code"
Am I missing a step in the setup?