gpt4 book ai didi

android - 如何在 Flutter 中集成 Instagram 登录

转载 作者:行者123 更新时间:2023-12-05 00:04:30 25 4
gpt4 key购买 nike

我想在我的应用中集成通过 instagram 登录

目前我正在使用下面的代码

Future<Token> getToken(String appId, String appSecret) async {
Stream<String> onCode = await _server();
String url =
"https://api.instagram.com/oauth/authorize?client_id=$appId&redirect_uri=http://localhost:8585&"
"response_type=code&scope=basic";
final flutterWebviewPlugin = new FlutterWebviewPlugin();
flutterWebviewPlugin.launch(url);
final String code = await onCode.first;
final http.Response response = await http.post(
"https://api.instagram.com/oauth/access_token",
body: {"client_id": appId, "redirect_uri": "http://localhost:8585", "client_secret": appSecret,
"code": code, "grant_type": "authorization_code"});
flutterWebviewPlugin.close();
return new Token.fromMap(json.decode(response.body));
}

Future<Stream<String>> _server() async {
final StreamController<String> onCode = new StreamController();
HttpServer server =
await HttpServer.bind(InternetAddress.loopbackIPv4, 8585);
server.listen((HttpRequest request) async {
final String code = request.uri.queryParameters["code"];
request.response
..statusCode = 200
..headers.set("Content-Type", ContentType.html.mimeType)
..write("<html><h1>You can now close this window</h1></html>");
await request.response.close();
await server.close(force: true);
onCode.add(code);
await onCode.close();
});
return onCode.stream;
}

我可以通过上面的代码在 Instagram 中登录

但是登录后出现以下错误

enter image description here

此外,我还在我的 info.plist 文件中添加了对 localhost:8585 的支持

<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost:8585</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>

如果需要更多信息,请告诉我。提前致谢。我们将不胜感激。

最佳答案

看到您的代码,我相信您正在关注 this blog posts执行。检查后,它使用“Instagram Legacy API 权限(“基本权限”)”。据我所知,正如评论部分所述,它于 2020 年 6 月被禁用。

这是 full text关于这个:

Update

The remaining Instagram Legacy API permission ("Basic Permission") wasdisabled on June 29, 2020. As of June 29, third-party apps no longerhave access to the Legacy API. To avoid disruption of service to yourapp and business, developers previously using the Legacy API shouldinstead rely on Instagram Basic DisplayAPIand Instagram GraphAPI. Pleaserequest approval for required permissions through the AppReview process.

Legacy API user identifier available on Basic Display API until September 30, 2020.
To assist with migration, we have temporarilymade the unique user identifier from the Legacy API - ig_id -available on Basic Display API. However, the ig_id field will bedeprecated on Basic Display API on September 30, 2020, so pleaseensure you are using other fields (e.g. the Facebook "id" field) oryour own unique identifier for your users. See our developerdocumentationhereto learn more.

User Token Generator
If you're only using the Legacy API to generate tokens in order to display your Instagram Feed on a personalwebsite, you can use the Instagram Basic Display API's User TokenGeneratorto continue generating tokens. The User Token Generator does notrequire App Review, but it will only work for your owned Instagramaccounts (i.e. accounts for which you know the login credentials).Refer to the developer documentationhereto learn more. If you're using the Legacy API to display multipleaccounts on your website, then you must apply for permissions toInstagram Basic DisplayAPIvia App Review. If you're using the Legacy API for any other use case,you must apply for permissions on the Instagram Graph APIplatformvia App Review.

More Tips
For more guidance on getting through our App Review process, please see this blogpost.For more tips and tools, check out our App Review Rejection ResultsGuide,Common AppReviewRejectionReasonsand Developer Tools page.We also encourage you to leverage the Facebook Developer CommunityForum - it's atremendously helpful resource for communicating and connecting withdevelopers across the world.

查看 this YouTube tutorial有关如何获取 Instagram 访问 token 的新指南。

关于android - 如何在 Flutter 中集成 Instagram 登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63109367/

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