gpt4 book ai didi

Facebook 访问 token 400 错误请求

转载 作者:行者123 更新时间:2023-11-30 05:20:12 29 4
gpt4 key购买 nike

我正在使用以下代码来检索 facebook accessToken

string url = "https://graph.facebook.com/oauth/access_token?" +
"client_id={0}" +
"&redirect_uri={1}" +
"&client_secret={2}" +
"&code={3}";
url = string.Format(url, clientId, redirectUri.EncodeUrl(), clientSecret, code);
//Create a webrequest to perform the request against the Uri
WebRequest request = WebRequest.Create(url);
try
{
//read out the response as a utf-8 encoding and parse out the access_token
using (WebResponse response = request.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
//string urlRedirects = response.ResponseUri.ToString();
Encoding encode = Encoding.GetEncoding("utf-8");
if (stream != null)
{
StreamReader streamReader = new StreamReader(stream, encode);
string accessToken = streamReader.ReadToEnd().Replace("access_token=", "");
streamReader.Close();
response.Close();
return accessToken;
}
}
}
}
catch
{
return null;
}

但是我不断收到这条模棱两可的错误信息

{
"error": {
"message": "Error validating verification code.",
"type": "OAuthException",
"code": 100
}
}

我检查了代码 100“无效参数”对我来说意义不大。

有人遇到过类似的问题吗?

最佳答案

  1. 检查您是否在 url 中添加了正确的代码例如

    http://www.xyz.com/?code=AQC399oXame3UKmoAMYnqkZOEXPDNa8ZUFEY9sc6I4YNQnNT-ZgHzpMNnQVZrCUBZVqJRIB1QrXC5xW58_8MNIgQol_PaQvYssUM8OiKjSY5aoqGLBMuCeeHsSqP_mRTd1xiK0iretZcXwMm_27lFYrWFw345Mxod_lfJuB8zI13E8wJUQiArXW_ZlGLNcyxh20#_=_

代码必须是

    code = AQC399oXame3UKmoAMYnqkZOEXPDNa8ZUFEY9sc6I4YNQnNT-ZgHzpMNnQVZrCUBZVqJRIB1QrXC5xW58_8MNIgQol_PaQvYssUM8OiKjSY5aoqGLBMuCeeHsSqP_mRTd1xiK0iretZcXwMm_27lFYrWFw345Mxod_lfJuB8zI13E8wJUQiArXW_ZlGLNcyxh20

代码不应该包含在最后

    #_=_ 

如果以上没有解决问题


2. redirect_uri 必须以/结尾

redirect_uri=http://www.xyz.com/

下面给出了一些上面提到的错误

redirect_uri=http://www.xyz.com


3.还要确保Facebook 上的应用程序使用 Facebook 登录的网站 设置了相同的地址例如 http://www.xyz.com/

关于Facebook 访问 token 400 错误请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10799235/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com