大家早上好!我用的是ASP。净HTTP API作为对谷歌的操作若乙方。我有一个错误消息,当我试图发送令牌对谷歌项目的行动。对于另一个问题我读我确定有明确的int值(而不是十进制),它不起作用。
我的JSON发送到谷歌上的动作:
{"token_type":"Bearer","access_token":"edeaa27e-12b7-43a1-bc7c-e6bbf9af71c3","refresh_token":"4344383b-cf07-4d12-a5c2-44b6481f5f48","expires_in":86400}
错误信息:
{
insertId: "1o7lj2bmu"
jsonPayload: {
@type: "type.googleapis.com/google.identity.accountlinking.type.AccountLinkingError"
errorReason: "Can't parse the response. The response needs to be JSON format."
response: {
body: ""{"token_type":"Bearer","access_token":"edeaa27e-12b7-43a1-bc7c-e6bbf9af71c3","refresh_token":"4344383b-cf07-4d12-a5c2-44b6481f5f48","expires_in":86400}""
status: 200
}
step: "AUTH_CODE_EXCHANGE"
}
logName: "projects/smartlightproject-f47f4/logs/accountlinking-pa.googleapis.com%2Ferror"
receiveTimestamp: "2022-07-12T12:32:40.739532642Z"
resource: {2}
severity: "ERROR"
timestamp: "2022-07-12T12:32:40.539Z"
}
JSON有什么问题?或者我应该用别的方法来做?如果你能帮我的话,我将非常非常感激。
这是我的一些改进后的代码:
var result_acceess_token = "edeaa27e-12b7-43a1-bc7c-e6bbf9af71c3";
var result_refresh_token = "4344383b-cf07-4d12-a5c2-44b6481f5f48";
var expires_expires_in = 86400;
var resultObj = new
{
token_type = "Bearer",
access_token = result_acceess_token,
refresh_token = result_refresh_token,
expires_in = expires_expires_in
};
return Ok(resultObj);
早些时候,我试图用JsonConvert序列化JSON,并将其返回为JsonResult或原始字符串值。
看起来您发送回的响应是JSON作为引号字符串。也就是说,JSON的开头和结尾都有一个引号。虽然这个是一个有效的JSON字符串(毕竟,它是一个带引号的字符串),但听起来像是在寻找一个JSON对象。
验证响应体,确保它不包含开、闭引号。