【发布时间】:2020-06-07 15:13:32
【问题描述】:
我想使用Instagram Basic Display API 从我的应用程序中获取authorization_code,但它不起作用。
我使用了这个代码:
String client_id = "my_client_id";
String oAuthUrl = "https://testsite.com/auth/";
String body_str = "?client_id=" + client_id +
"&redirect_uri=" + oAuthUrl +
"&scope=user_profile,user_media" +
"&response_type=code";
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.instagram.com/oauth/authorize" + body_str).get().build();
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String ans = response.toString();
}
});
在response 中,我收到了新的登录请求,但没有被重定向到 Instagram。
这是我的response:
Response{protocol=h2, code=200, message=, url=https://www.instagram.com/accounts/login/?force_authentication=1&enable_fb_login=1&platform_app_id=my_client_id&next=/oauth/authorize%3Fclient_id%3Dmy_client_id%26redirect_uri%3Dhttps%3A//testsite.com/auth/%26scope%3Duser_profile%2Cuser_media%26response_type%3Dcode}
注意:我的请求网址在 chrome 中运行良好,我被重定向到包含 authorization_code 的新网址,但我无法在我的应用程序中执行此操作。
请指导我。
谢谢
【问题讨论】:
标签: android instagram-api