重要提示:自
2024 年 5 月 1 日起,对于使用常用 SDK(包括 GoogleSignIn-iOS)的 iOS 应用,Apple
要求提供隐私权清单和签名。请在 2024 年 5 月 1 日之前升级到 GoogleSignIn-iOS v7.1.0 及更高版本。按照
我们的升级指南操作。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
撤消访问令牌并断开应用
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
强烈建议您为使用 Google 登录的用户提供断开其 Google 账号与您的应用之间关联的功能。如果用户删除了其账号,您必须删除您的应用从 Google API 获取的信息。
以下代码示例演示了如何以编程方式撤消您的应用代表用户获得的访问令牌,以及如何断开用户账号与您的应用之间的关联。
Swift
GIDSignIn.sharedInstance.disconnect { error in
guard error == nil else { return }
// Google Account disconnected from your app.
// Perform clean-up actions, such as deleting data associated with the
// disconnected account.
}
Objective-C
[GIDSignIn.sharedInstance disconnectWithCompletion:^(NSError * _Nullable error) {
if (error) { return; }
// Google Account disconnected from your app.
// Perform clean-up actions, such as deleting data associated with the
// disconnected account.
}];
disconnectWithCompletion: 方法除了断开用户账号的关联和撤消令牌之外,还会让用户退出登录。您不得在调用 disconnectWithCompletion: 之前让用户退出登录。
然后,您可以在回调块中响应成功断开关联的操作,并在您的应用或后端代码中触发任何适当的逻辑。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2026-05-13。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2026-05-13。"],[],[]]