如何使用flutter_appauth注销? [英] How to logout with flutter_appauth?

查看:85
本文介绍了如何使用flutter_appauth注销?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从 flutter_appauth 中注销,并按下一个按钮;

I need to logout from flutter_appauth with a button press in flutter;

此软件包没有任何注销方法.

This package doesn't have any logout method.

这是我的获取令牌代码:

This is my get token code:

appAuth.authorizeAndExchangeCode(AuthorizationTokenRequest(
                clientID, redirectUrl,
                discoveryUrl: discoveryUrl,
                scopes: scopes,
                clientSecret: clientSecret

推荐答案

这里有2个主要选项,并且第一步,我将看看是否可以使第一个选项起作用,这与Mohammad的评论一致:

There are 2 main options here, and as a first step I would see if you can make the first option work, in line with Mohammad's comment:

选项1:简单注销

只需从您的应用中删除所有存储的令牌即可.问题是它不会删除授权服务器会话Cookie.因此,默认情况下,您不能强制另一个登录提示,例如以新用户身份登录.解决此问题的一种方法是在执行登录重定向时发送 prompt = login 作为参数.

Just remove any stored tokens from your app. The problem with this is that it does not remove the Authorization Server Session Cookie. So by default you cannot force another login prompt, eg to sign in as a new user. One way around this is to send prompt=login as a parameter when performing the login redirect.

选项2:完全注销

完整注销涉及这两个操作,并且可能需要您深入研究AppAuth内部:

A full logout involves both of these actions and may require you to dig into AppAuth internals:

  • 从您的应用中删除存储的令牌
  • 通过结束会话请求重定向以删除授权服务器会话cookie

这是一些

Here is some sample Android code of mine to spin up a Chrome Custom Tab for a logout redirect.

还有其他潜在问题,例如由于用户手势丢失而导致断断续续的Chrome白屏无法在注销后返回到应用程序的情况.

There are other potential issues, such as intermittent Chrome white screens that fail to return to the app after logout, due to a missing user gesture.

更多信息

我的博客文章进一步介绍了有关AppAuth集成的详细信息,以及可以运行的代码示例(如果有帮助的话).我直接从Kotlin/Swift使用AppAuth库,而您需要处理Flutter插件的另一层:

My blog posts have some further details on AppAuth integration, along with code samples you can run, in case any of this is useful. I am using AppAuth libraries directly from Kotlin / Swift, whereas you need to deal with an additional layer of the Flutter Plugin:

这篇关于如何使用flutter_appauth注销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆