无法从 Angel.co API 调用 Android 应用重定向回应用
Cannot get redirected back to App from Angel.co API call in Android App
我有一个通过以下调用对用户进行身份验证的应用程序:
https://angel.co/api/oauth/authorize?
client_id=...&
state=...&
response_type=code
我已经设置了以下代码来进行身份验证,然后获取 AccessToken 的代码:
mLoginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("https://angel.co/api/oauth/authorize?"
+ "client_id=" + clientId + "&"
+ "response_type=" + RESPONSE_TYPE)
);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
这是我的清单:
<activity android:name=".ui.UserLoginActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:exported="true"
android:screenOrientation="portrait">
<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:host="myapp"
android:scheme="dezign.scheme" />
</intent-filter>
</activity>
当我点击 mLoginButton
时,它从应用程序启动到 Chrome 浏览器正常,但是当它完成并点击 redirectUri
时,它显示以下错误并返回到应用程序:
我在这里做错了什么?到目前为止,我还没有在 SO 上找到可接受的答案。
更新似乎解决了问题
现在可以使用了!
我的方案和主机有误,有关这方面的更多文档,请在此处查看以下 link:
我的主机和方案是倒退的,它应该是这样的:
对于我的应用程序,具体应该是:
android:scheme="myapp"
android:host="dezign.scheme"
我有一个通过以下调用对用户进行身份验证的应用程序:
https://angel.co/api/oauth/authorize?
client_id=...&
state=...&
response_type=code
我已经设置了以下代码来进行身份验证,然后获取 AccessToken 的代码:
mLoginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(
Intent.ACTION_VIEW,
Uri.parse("https://angel.co/api/oauth/authorize?"
+ "client_id=" + clientId + "&"
+ "response_type=" + RESPONSE_TYPE)
);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
});
这是我的清单:
<activity android:name=".ui.UserLoginActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:exported="true"
android:screenOrientation="portrait">
<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:host="myapp"
android:scheme="dezign.scheme" />
</intent-filter>
</activity>
当我点击 mLoginButton
时,它从应用程序启动到 Chrome 浏览器正常,但是当它完成并点击 redirectUri
时,它显示以下错误并返回到应用程序:
我在这里做错了什么?到目前为止,我还没有在 SO 上找到可接受的答案。
更新似乎解决了问题
现在可以使用了!
我的方案和主机有误,有关这方面的更多文档,请在此处查看以下 link:
我的主机和方案是倒退的,它应该是这样的:
对于我的应用程序,具体应该是:
android:scheme="myapp"
android:host="dezign.scheme"