Android 如何在Flatter中集成instagram sign
我想通过instagram在我的应用程序中集成登录 目前我正在使用下面的代码Android 如何在Flatter中集成instagram sign,android,flutter,dart,instagram,instagram-api,Android,Flutter,Dart,Instagram,Instagram Api,我想通过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&red
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遗留API许可(“基本许可”)已于2020年6月29日禁用。截至6月29日,第三方应用程序不再能够访问旧版API。您是否尝试过此URL:?@Goku您找到解决方案了吗?
<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>