【发布时间】:2021-11-05 09:28:54
【问题描述】:
我希望这是有道理的。我正在使用 Zoho C# SDK 示例将记录写入 CRM Leads。在调用 recordOperations.CreateRecords();尝试从令牌存储中获取令牌后失败。 这是我要保存的令牌
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);
我正在将此令牌发送到 SDKInitilizer.Initialize。此时没有错误。接下来,我尝试创建一个潜在客户。当它进入 recordOperations.CreateRecords();它尝试 GetToken 并且我已经对其进行了硬编码以准确返回上面令牌对象中的内容。 CreateRecords 为“invalid_code”引发错误。这是日志文件中的内容
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}
它在尝试刷新令牌时似乎失败了,所以我认为我没有在令牌对象中发送正确的信息?
*** 编辑@sucasa *** 这就是我发送到 Initialize 方法的内容。
自从我的第一篇文章以来,我发现,我没有从 Initialize 获得初始的 token,它没有调用我创建的自定义 TokenStore.SaveToken(),它应该,对吗?如果我保存它,我所拥有的只是上面的,而不是实际的token。所以我认为当我去创建潜在客户时,我实际上并没有要刷新的初始令牌。我希望这更清楚。
【问题讨论】:
标签: c# authentication zoho