android - oauth2 : Logoff currently logged in google user and then send the oauth url from my app

标签 android oauth-2.0 logoff

假设 user1 已经在我手机的 chrome 浏览器上登录了他的 gmail 帐户。 我正在使用 google rest api 编写一个 android 应用程序,先决条件是 oauth2 授权。如果我从我的应用程序发送授权 url 以在浏览器中打开,则假定 user1 的帐户已通过身份验证并显示授权页面(带有允许/拒绝)按钮。我如何以编程方式注销现有用户,然后从我的应用程序发送 oauth2 url,以便用户明确输入他的凭据并授予 oauth 访问我的应用程序的权限。

我尝试使用以下方式注销但没有成功...

1) https://www.google.com/accounts/logoff?continue=https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A8080&prompt=consent&response_type=code&client_id=blah-blah-blah "&scope="blah blah"

2) https://accounts.google.com/logoff?continue=https://accounts.google.com/o/oauth2/v2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A8080&prompt=consent&response_type=code&client_id=blah-blah-blah "&scope="blah blah"

在选项 2 和 3 中,我收到一个 http 400 错误,指出缺少“response_type”,但它出现在我发送的 url 中。

基本上我的 Intent 是注销现有的 google 用户并明确让我的应用程序的用户登录他的凭据,以便 oauth2 只针对他的帐户而不是其他人(错误地)完成。

最佳答案

我在 http 请求中添加了参数“prompt=select_account+consent”,它对我有用。无论当前登录浏览器的用户是谁,都会为用户显示登录屏幕。

https://accounts.google.com/o/oauth2/v2/auth?prompt=select_account+consent

关于android - oauth2 : Logoff currently logged in google user and then send the oauth url from my app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43413952/

相关文章:

android - 如何通过知道元素 id 滚动到 ScrollView 中的特定 View 元素

Azure Multi-Tenancy 应用程序未获取具有新定义范围的 token

java - 使用java注销计算机

asp.net-mvc-4 - MVC AZURE WA AD 不带 ACS 退出

asp.net - 用户下线时间

javascript - React Native 可以用来构建我的蓝牙应用程序吗?

android - 获取文本空间边界

java - android应用程序中如何处理域认证?

java - 为网站创建 API

python - 在不离开页面的情况下使用 django-allauth 进行社交登录