flutter - 如何修复 Flutter 中的“由于缺少初始状态而无法处理请求。”,来源:https://{org-name}/__/auth/handler.js
问题描述
我正在尝试在我的颤振应用程序中设置社交登录。谷歌和 Facebook 登录工作正常,但是当我尝试使用 github 登录时,它会打开一个网页询问我的 github 凭据,当我点击登录时,我得到了这个。
由于缺少初始状态,无法处理请求。”,来源:https://{org-name}/__/auth/handler.js
我有一个以 MongoDB 作为数据库的自定义后端。我尝试注册的代码/登录是:
Navigator.of(context).pushReplacement(MaterialPageRoute(
builder: (context) => Scaffold(
body: SafeArea(
child: Builder(
builder: (context) => WebView(
userAgent: "random",
initialUrl:
'https://{orgname}.herokuapp.com/api/auth/$url',
javascriptMode: JavascriptMode.unrestricted,
navigationDelegate: (navigation) async {
if (navigation.url.startsWith(
'https://{org-name}.herokuapp.com/api/auth/$url/callback')) {
print('success');
http.Response response =
await http.get(Uri.parse(navigation.url));
print('response is ${response.body}');
final storage = FlutterSecureStorage();
var parsedBody = json.decode(response.body);
await storage.write(key: "token", value: parsedBody["token"]);
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => Home(),
));
}
return NavigationDecision.navigate;
},
),
)),
),
));
}
在 Androidmanifest.xml 我只有这个:
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
和这个
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
请帮忙。
解决方案
推荐阅读
- javascript - 在博客中将谷歌字体添加到我的博客时,我在标题部分出现错误
- instagram-graph-api - 如何使用 instagram graph api 获取用户电子邮件和全名
- javascript - 更改 jQuery 中继器删除按钮的效果
- split - 如何在pytorch中拆分文件夹中的数据集?
- snowflake-cloud-data-platform - 我是否需要拥有该对象才能在雪花中访问它?
- python - 如何在 Tensorflow 2.0 数据集中动态更改批量大小?
- html - 我在哪里可以找到我的 github 静态网页的实时 html?
- php - 如何在添加更多按钮的末尾删除多余的空列
- html - 如何使用同名标签捕获表单中不同字段的数据?
- ansible - 如何使用具有从hostvars接收值的变量的ansible模板模块?