我正在尝试从一个基于OAuth2的服务器使用隐式授权使用AppAuth获取AccessToken。
在此之后,下面的代码重定向到浏览器以进行登录
AuthorizationService service = new AuthorizationService(this,
new AppAuthConfiguration.Builder().setBrowserMatcher(blacklist).build());
service.performAuthorizationRequest(request,
PendingIntent.getActivity(this, request.hashCode(),new Intent(this,ReceiverActivity.class),0));
service.dispose();当我在上面的代码中使用ReceiverActivity从浏览器返回到应用程序时,然后在:
public viod onStart(){
AuthorizationResponse response = AuthorizationResponse.fromIntent(getIntent()); //null
AuthorizationException ex = AuthorizationException.fromIntent(getIntent());// exception below
}
{"type":0,"code":9,"errorDescription":"Response state param did not match request state"}其他:
AuthorizationRequest request = new AuthorizationRequest.Builder(
authorizationServiceConfiguration,
"clientid",
"token",
Uri.parse(CONSTANTS.REDIRECT_URL)
).setScope("crm_read")
.setAdditionalParameters(autoApprove)
.build();清单
<activity android:name="net.openid.appauth.RedirectUriReceiverActivity">
<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="${appAuthRedirectScheme}"
android:host="com.crm.crm"
android:path="/oauth2callback"/>
</intent-filter>
</activity>那么,为什么我得到这个错误{"type":0,"code":9,“errorDescription”:“响应状态参数不匹配请求状态”}我需要在链接中设置一些东西吗?
发布于 2018-05-01 03:05:15
这里是AppAuth的主要维护者-我们不支持库中的隐式流,因为它不适合本机应用程序:它的安全性很差,并且需要用户频繁地通过web流进行身份验证(通常是每隔7-30天)。建议基于代码的流程,其中可以获取刷新令牌,这将仅需要应用程序通过web流进行一次身份验证,之后它可以使用刷新令牌透明地获取新的访问令牌。
发布于 2019-02-12 02:05:39
根据IdentityServer4文档,隐式授权类型针对基于浏览器的应用程序进行了优化。因此,不推荐用于移动应用程序。对于移动应用程序,您应该考虑混合流(代码id_token)。
https://stackoverflow.com/questions/50105841
复制相似问题