首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AppAuth隐式授权

AppAuth隐式授权
EN

Stack Overflow用户
提问于 2018-05-01 01:59:51
回答 2查看 647关注 0票数 0

我正在尝试从一个基于OAuth2的服务器使用隐式授权使用AppAuth获取AccessToken。

在此之后,下面的代码重定向到浏览器以进行登录

代码语言:javascript
复制
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从浏览器返回到应用程序时,然后在:

代码语言:javascript
复制
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"}

其他:

代码语言:javascript
复制
AuthorizationRequest request = new AuthorizationRequest.Builder(
                authorizationServiceConfiguration,
                "clientid",
                "token",
                Uri.parse(CONSTANTS.REDIRECT_URL)
        ).setScope("crm_read")
                .setAdditionalParameters(autoApprove)
                .build();

清单

代码语言:javascript
复制
 <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”:“响应状态参数不匹配请求状态”}我需要在链接中设置一些东西吗?

EN

回答 2

Stack Overflow用户

发布于 2018-05-01 03:05:15

这里是AppAuth的主要维护者-我们不支持库中的隐式流,因为它不适合本机应用程序:它的安全性很差,并且需要用户频繁地通过web流进行身份验证(通常是每隔7-30天)。建议基于代码的流程,其中可以获取刷新令牌,这将仅需要应用程序通过web流进行一次身份验证,之后它可以使用刷新令牌透明地获取新的访问令牌。

票数 2
EN

Stack Overflow用户

发布于 2019-02-12 02:05:39

根据IdentityServer4文档,隐式授权类型针对基于浏览器的应用程序进行了优化。因此,不推荐用于移动应用程序。对于移动应用程序,您应该考虑混合流(代码id_token)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50105841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档