我使用 Volley
在我的 Android 应用程序中发送 HTTP 请求。我在互联网上寻找了很多答案,但没有找到任何东西。
我使用 Blogger API 并发送 HTTP
请求,以使用文档中给出的通过 URL 获取博客方法获取我的博客
GET https://www.googleapis.com/blogger/v3/users/self/blogs
Authorization: /* OAuth 2.0 token here */
我按照文档中的说明,在 getHeaders()
方法中正确添加了授权 header :
@Override
public Map<String, String> getHeaders() {
HashMap<String, String> params = new HashMap<>();
params.put("Authorization", "My_Auth_Key");
return params;
}
正如您所看到的,我还在 google API 控制台中正确完成了设置过程。我正确添加了我的包名称,即 gq.gouravkhunger.blogger
和应用程序的 SHA Fingerprint
:
但是当我测试应用程序时,我总是收到此错误:
最佳答案
您确定您的 OAUTH key 有效吗? 并且还要确保您没有在应该使用 OAUTH 的地方使用 APIKey。 阅读文档以更好地理解
您可以从OAUTH Playground获取OAUTH Key用于测试
关于android - Blogger api 总是返回 401 错误响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53816189/