gpt4 book ai didi

java - 推特。验证_凭据。 OAuth API。错误 "Could not authenticate you."Include_email=true

转载 作者:行者123 更新时间:2023-12-04 03:09:43 26 4
gpt4 key购买 nike

如果我包含参数“Include_email=true”,我会收到“无法验证您的身份”错误。

这里是代码。请帮忙。

public final static String VERIFY_CREDENTIALS_URL ="https://api.twitter.com/1.1/account/verify_credentials.json";

public final static String AUTHORIZATION_VERIFY_CREDENTIALS = "OAuth " +
"oauth_consumer_key=\"{key}\", " +
"oauth_signature_method=\"" + SIGNATURE_METHOD + "\", " +
"oauth_timestamp=\"{ts}\", " +
"oauth_nonce=\"{nonce}\", " +
"oauth_version=\"1.0\", " +
"oauth_signature=\"{signature}\", " +
"oauth_token=\"{token}\"";

public static TwitterVerifyCredentials getVerifyCredentials(String appKey, String appSecret, TwitterAccessToken accessToken) throws GeneralSecurityException, IOException {
String ts = "" + TimeUtility.now().getTime()/1000;
String oauth_nonce = UUID.randomUUID().toString().replaceAll("-", "");
String parameters = "oauth_consumer_key=" + appKey + "&oauth_nonce=" + oauth_nonce + "&oauth_signature_method=" + SIGNATURE_METHOD + "&oauth_timestamp=" + ts + "&oauth_token=" + encode(accessToken.getToken()) + "&oauth_version=1.0";
String signature = "GET&" + encode(VERIFY_CREDENTIALS_URL) + "&" + encode(parameters);
System.out.println(signature);

String result = TwitterOAuth.AUTHORIZATION_VERIFY_CREDENTIALS;
result = StringUtils.replace(result, "{nonce}", oauth_nonce);
result = StringUtils.replace(result, "{ts}", "" + ts);
result = StringUtils.replace(result, "{key}", appKey);
result = StringUtils.replace(result, "{signature}", encode(computeSignature(signature, appSecret + "&" + encode(accessToken.getTokenSecret()))));
result = StringUtils.replace(result, "{token}", encode(accessToken.getToken()));

HashMap<String, String> headers = new HashMap<>();
headers.put("Authorization", result);

String s = SiteFunctions.urlGet(VERIFY_CREDENTIALS_URL+"?include_email=true", headers);
System.out.println(s);
return new TwitterVerifyCredentials(); // while testing
}

如果我删除“?include_email=true”一切都很好!

最佳答案

VERIFY_CREDENTIALS_URL 在您的程序中应添加 ?include_email=true。如果你想从 Twitter OAuth api 获取电子邮件,签名中的 url 应该有 ?include_email=true

关于java - 推特。验证_凭据。 OAuth API。错误 "Could not authenticate you."Include_email=true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46232199/

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