Getting a Oauth token from c# SDK
I hope this makes sense. I am using the c# SDK examples to write records to the CRM Leads. While calling While this is not all my code, I'm hoping its enough to get some help. While calling recordOperations.CreateRecords(); it fails after trying to GetToken from the Token Store.
Here is the token I am saving
- Token token = new OAuthToken(
- "xxxx.clientid.goes.here.xxxxx",
- "xxxx.clientsecret.goes.here.xxxx",
- "REFRESH/GRANT token",
- TokenType.GRANT,
- string.Empty);
- TokenStore tokenStore = new CustomTokenStore();
- tokenStore.SaveToken(user, token);
And I am sending this token into the SDKInitilizer.Initialize. No errors at this point. Next I try and create a lead. When it gets inside of recordOperations.CreateRecords(); it tries GetToken and I've hard coded it to return exactly what was in the token object above. CreateRecords throws an error for "invalid_code". Here is what is in the log file
- 21-09-07 16:49:34 [INFO]: Initialization successful for Email Id : myemail@email.com in Environment : https://www.zohoapis.com.
- 21-09-07 16:49:47 [INFO]: Access Token has expired. Hence refreshing.
- 21-09-07 16:49:50 [ERROR]: Exception in authenticating current request : {"Code":"INVALID CLIENT ERROR","Message":"invalid_code","Cause":null,"Details":null,"StackTrace":" at Com.Zoho.API.Authenticator.OAuthToken.ParseResponse(String response)\r\n at Com.Zoho.API.Authenticator.OAuthToken.RefreshAccessToken(UserSignature user, TokenStore store)\r\n at Com.Zoho.API.Authenticator.OAuthToken.Authenticate(APIHTTPConnector urlConnection)\r\n at Com.Zoho.Crm.API.Util.CommonAPIHandler.APICall[T](Type className, String encodeType)","Data":{},"InnerException":null,"HelpLink":null,"Source":"ZCRMSDK","HResult":-2146233088}
It appears to be failing when it tries to refresh the token so I assume I am not sending in the right info in the token object?