【发布时间】:2022-02-01 04:22:06
【问题描述】:
所以我正在尝试从 Instagram API 获取访问令牌。它显示在 Postman 中,但未显示在响应正文中
onPageStarted: (url) async {
print("url is " + url);
if (url
.startsWith("https://aymen-ziouche.github.io/Gaming-website/")) {
Navigator.pop(context);
var uri = Uri.parse(url);
final String? code = uri.queryParameters["code"];
print("this's the code: $code");
final response = await dio
.post('https://api.instagram.com/oauth/access_token', data: {
'client_id': Constants.igClientId,
'client_secret': Constants.igClientSecret,
'grant_type': "authorization_code",
'redirect_uri': Constants.igRedirectURL,
'code': code
});
print("token is => ${response.data}");
print("response => ${response.statusCode} ${response.data}");
}
},
这是日志:
I/flutter (21891): url is https://aymen-ziouche.github.io/Gaming-website/?code=AQDIXj5sEEPfgHv_U5dcw3A9zQbWjR9w37MTWg9f153UAJsyHcG34iNtSgxH9sswpBvHrB1CobZBgReCx4GhCIeq5HiLfIDRe8c_HNS_U_7CQ5fVdP6JdS1vLxQua4iA706q9lik08r_C9aAFLm6oT0hJeQVXcHiwTqJWLxxyXxWhtmeClBYwlIoSJKp8gcf-rft6QrVOolBcXg6LCB6Vj9W7Dr3k4QiqsDVN0vX2uvAsw#_
I/flutter (21891): this's the code: AQDIXj5sEEPfgHv_U5dcw3A9zQbWjR9w37MTWg9f153UAJsyHcG34iNtSgxH9sswpBvHrB1CobZBgReCx4GhCIeq5HiLfIDRe8c_HNS_U_7CQ5fVdP6JdS1vLxQua4iA706q9lik08r_C9aAFLm6oT0hJeQVXcHiwTqJWLxxyXxWhtmeClBYwlIoSJKp8gcf-rft6QrVOolBcXg6LCB6Vj9W7Dr3k4QiqsDVN0vX2uvAsw
I/flutter (21891): token is =>
I/flutter (21891): response => 200
我修好了。问题出在 dio.options() 我添加了这个:Options(responseType: ResponseType.json)
【问题讨论】:
-
如果您提供日志的屏幕截图会很有帮助......就像 API 正在准确回复一样
-
是的,对不起。在这里