关键词:
【中文标题】带有 Google 登录帐户的 Google API【英文标题】:GoogleAPI with Google Sign In Account 【发布时间】:2020-08-14 18:10:02 【问题描述】:我已在我的应用程序中使用 firebase auth 实现了 google 登录。 我正在尝试使用登录的 google 帐户实现 GmailAPI,但无法同时找到有关它们的任何信息。 我正在跟进 https://github.com/dart-lang/googleapis/blob/master/generated/googleapis/lib/gmail/v1.dart 并在代码中实现了这一点
final FirebaseAuth _auth = FirebaseAuth.instance;
final GoogleSignIn googleSignIn = GoogleSignIn(
scopes: [
"https://www.googleapis.com/auth/gmail.compose",
"https://www.googleapis.com/auth/gmail.insert",
"https://www.googleapis.com/auth/gmail.labels",
"https://www.googleapis.com/auth/gmail.metadata",
"https://www.googleapis.com/auth/gmail.modify",
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/gmail.send",
"https://www.googleapis.com/auth/gmail.settings.basic",
"https://www.googleapis.com/auth/gmail.settings.sharing",
]
);
用户是否需要在此之后进行身份验证,或者由此生成的uid
足以对用户进行身份验证?
在网上到处都有 googleAPI 示例,用户在网上通过身份验证,我找不到任何 google sign in
的东西。
【问题讨论】:
Github 链接对我不可用,而且它们的公共回购为零:github.com/dartlang @csgabriella github.com/dart-lang/googleapis/blob/master/generated/… 他们昨天更新了链接 您可能不会使用uid
进行身份验证,您可能会使用token
进行身份验证。话虽如此,我已经通过 firebase 设置了 oauth 很多次,而且我从来没有遇到过任何超级复杂的事情,所以如果它变得超级复杂,请返回文档
@ewizard 请检查我在此之后提出的问题。当新用户使用 google 登录应用程序时,它会询问我在范围中添加的邮件设置的权限。现在是什么意思?
【参考方案1】:
我不是颤振专家,但根据here 找到的示例,您需要以编程方式验证firebase 的唯一内容是token_id
和access_token
,就像这样:
final AuthCredential credential = GoogleAuthProvider.getCredential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
据此,要向 firebase 进行身份验证,您只需添加登录范围:'email', 'profile' and 'openid'
或范围:'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile' and 'openid'
(它们通常表示相同,具体取决于所使用的库)。然后使用生成的访问令牌,您可以使用 firebase 库对 firebase 进行身份验证,而无需重新进行身份验证。
如果您需要更多信息,请告诉我。
编辑:
您必须找到 Google 登录收到的访问令牌并传递信息以进行 Firebase 登录。访问令牌应如下所示:
"access_token": "ya29.a0Adw1xekVMTQRK0_EAdr1PfiOS97Lnz-VCLTJHw7...",
"expires_in": 3599,
"refresh_token": "1//01iBd1CQsBUl2CgYIARAA...",
"scope": "https://www.googleapis.com/auth/userinfo.email openid",
"token_type": "Bearer",
"id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjE31ZmY0ZTEwOTkxZDZiMGA..."
【讨论】:
使用旧密码登录 Google 帐户 - 如何重定向到蓝色 Google 登录页面?
】使用旧密码登录Google帐户-如何重定向到蓝色Google登录页面?【英文标题】:SignintoGoogleaccountwitholdpassword-howtoredirecttoblueGoogleSign-Inpage?【发布时间】:2019-07-1515:37:01【问题描述】:我已在我的应用程序中实现了GoogleSign-InSDK,它... 查看详情
如何将 google 帐户链接到本地帐户以进行 google oauth2 登录
】如何将google帐户链接到本地帐户以进行googleoauth2登录【英文标题】:Howtolinkgoogleaccounttolocalaccountforgoogleoauth2login【发布时间】:2016-04-0413:13:59【问题描述】:我想从普通的用户名和密码登录切换到GoogleforSpringSecurityOAuth插件... 查看详情
Google+ 登录将用户注销
...录多个Google帐户时,我遇到了问题。我的应用程序有一个带有Google+登录按钮的登录页面。用户单击按钮并授权应用程序。signinCallback被正确触发。然后应用程序会呈现一个新页面,该页面具有隐藏的登录按钮(允许用户退出)。... 查看详情
Google 帐户登录错误(双重身份验证)[关闭]
】Google帐户登录错误(双重身份验证)[关闭]【英文标题】:GoogleAccountsign-inerror(two-factorauthentication)[closed]【发布时间】:2012-06-3001:34:39【问题描述】:我在Galaxy10.1选项卡上使用Google双重身份验证,并收到关于我的Google帐户“登... 查看详情
使用不同帐户的 Google 登录在应用程序中崩溃
】使用不同帐户的Google登录在应用程序中崩溃【英文标题】:GoogleSigninfromdifferentaccountcrashesintheapp【发布时间】:2019-10-1915:45:57【问题描述】:我已将谷歌登录集成到我的应用中。我点击按钮并选择“从其他帐户登录”,让用户... 查看详情
Firebase - 检查使用 Google 帐户创建的用户是不是正在注册或登录?
】Firebase-检查使用Google帐户创建的用户是不是正在注册或登录?【英文标题】:Firebase-checkifusercreatedwithGoogleAccountissigninguporloggingin?Firebase-检查使用Google帐户创建的用户是否正在注册或登录?【发布时间】:2021-10-2313:00:14【问题... 查看详情
带有服务帐户的 Google Calendar Python API 未返回任何结果
】带有服务帐户的GoogleCalendarPythonAPI未返回任何结果【英文标题】:GoogleCalendarPythonAPIwithserviceaccountreturningnoresults【发布时间】:2014-09-0111:36:27【问题描述】:我正在尝试下载我的用户可以看到的Google日历列表。我已经设置了一... 查看详情
Firebase 使用 Google 帐户覆盖登录
】Firebase使用Google帐户覆盖登录【英文标题】:FirebaseOverwritesSigninwithGoogleAccount【发布时间】:2017-04-0713:43:19【问题描述】:文档中似乎没有提到这一点,我发现的只是this和this,我想在这里确认一下:如果现有帐户具有相同的电... 查看详情
带有服务帐户的 Google Cloud Pub Sub
】带有服务帐户的GoogleCloudPubSub【英文标题】:GoogleCloudPubSubWithServiceAccount【发布时间】:2018-12-1508:51:21【问题描述】:大家好,我遇到了一个让我发疯的pubsub问题。基本上我有一个用于pubsub的具有管理员权限的服务帐户,但我... 查看详情
带有 Google 服务帐户主题的 generate_access_token()
】带有Google服务帐户主题的generate_access_token()【英文标题】:generate_access_token()withsubjectforGoogleserviceaccount【发布时间】:2021-10-0716:36:07【问题描述】:在python中,我试图通过Delegateddomain-wideauthority的服务帐户调用GMailAPI,没有使用... 查看详情
在 SwiftUI 中使用 google 帐户登录后是不是有任何改变视图的方法?
】在SwiftUI中使用google帐户登录后是不是有任何改变视图的方法?【英文标题】:IsthereanywaytochangeyourviewafterlogginginwithagoogleaccountinSwiftUI?在SwiftUI中使用google帐户登录后是否有任何改变视图的方法?【发布时间】:2019-12-1114:40:34【... 查看详情
如何在使用 Google 登录按钮时不将 Google 帐户添加到 Android 手机
】如何在使用Google登录按钮时不将Google帐户添加到Android手机【英文标题】:HowtoNOTaddGoogleaccounttoAndroidphonewhileusingGoogleSign-InButton【发布时间】:2020-07-0205:46:05【问题描述】:我在我的Android应用程序中是integratingGoogle-Signbutton。但... 查看详情
使用 google 登录可防止用户使用其他帐户再次登录 - iOS
】使用google登录可防止用户使用其他帐户再次登录-iOS【英文标题】:Signinwithgooglepreventstheusertosigninagainwithdifferentaccount-iOS【发布时间】:2018-08-2116:56:55【问题描述】:我正在使用google身份验证通过firebase登录。身份验证过程运行... 查看详情
使用 Firebase 登录 Google - 获取机器人帐户
】使用Firebase登录Google-获取机器人帐户【英文标题】:GoogleSigninwithFirebase-Gettingbotaccounts【发布时间】:2021-02-0100:08:54【问题描述】:我正在创建一个使用Firebase实时数据库的Android应用。我的firebase项目仅限于Google登录,而数据库... 查看详情
带有 Java 的 Google Calendar API - 服务帐户
】带有Java的GoogleCalendarAPI-服务帐户【英文标题】:GoogleCalendarAPIwithJava-ServiceAccount【发布时间】:2017-12-0512:49:48【问题描述】:引用GoogleCalendarAPIwithPHP–ServiceAccount并尝试了以下步骤:在GoogleAPI控制台中创建了一个项目并在该项... 查看详情
Google 服务帐户用户界面
】Google服务帐户用户界面【英文标题】:GoogleServiceaccountuserinterfece【发布时间】:2015-07-1310:06:59【问题描述】:如何使用普通的网络用户界面登录GoogleServiceaccount,例如googledrive?现在我只能使用脚本使用API登录。【问题讨论】... 查看详情
“使用其他帐户”登录时,Google 登录不返回任何结果
】“使用其他帐户”登录时,Google登录不返回任何结果【英文标题】:GoogleSignindoesn\'treturnanyresultwhen\'Useanotheraccount\'tosignin【发布时间】:2018-10-1108:31:45【问题描述】:这似乎是一个基本功能,但是在关注signing-intutorial之后,它... 查看详情
如何创建 Microsoft 帐户登录到我的网站,类似于 Google?
】如何创建Microsoft帐户登录到我的网站,类似于Google?【英文标题】:HowtocreateMicrosoftAccountSign-intomywebsite,similartoGoogle?【发布时间】:2018-02-2518:34:26【问题描述】:我正在开发一个网络项目(HTML、CSS、JavaScript,后端使用PHP)。... 查看详情