我在谷歌云中有一个网站。我使用身份识别代理(IAP)来保护它。
当IAP中的请求检查我是否已获得授权,然后以
响应现在我想在此基础上使用Google Sign-In for Websites。
这可能看起来多余,因为我在看到按钮时已经登录但我想将其用作注销或更改用户帐户的方式。
现在我试图做的是:
private func swapSquares(square1: Square, square2: Square) {
if square1.chessPiece == nil && square2.chessPiece == nil {
return
}
var square1ChessPiece: ChessPiece?
var square2ChessPiece: ChessPiece?
if let square1piece = square1.chessPiece {
square1ChessPiece = square1piece
}
if let square2piece = square2.chessPiece {
square2ChessPiece = square2piece
}
if let square1piece = square1ChessPiece {
square1piece.frame = square2.frame
square1piece.square = square2
square2.chessPiece = square1piece // after this, square1ChessPiece and Square2Chess become the same
}
if let square2piece = square2ChessPiece {
square2piece.frame = square1.frame
square2piece.square = square1
square1.chessPiece = square2piece
}
}
这似乎有效,除非它向我显示一个登录框,即使我已登录可疑。
当我这样做时加上
var auth2 = gapi.auth2.init({
client_id: 'mykey.apps.googleusercontent.com',
})
auth2.isSignedIn.get()
// false, I was hoping that I could somehow piggyback on my existing session
auth2.signIn()
// shows a pop up, allowing me to select an account
auth2.isSignedIn.get()
// true
currentUser.getBasicProfile()
// works
然后进行全面刷新,然后我仍然从IAP获取资源,证明我仍然在那里登录。
问题:
答案 0 :(得分:1)
我对网站登录并不了解,但还有另一种选择可能对您有用。您是否考虑过添加/ _gcp_iap / clear_login_cookie的链接以提供更改用户帐户"选项? (它在此处记录:https://cloud.google.com/iap/docs/special-urls-howto)
如果用户使用多个Google帐户登录,则会将其退回到帐户选择器。今天,如果他们只使用一个帐户登录,它只会将它们发送回应用程序 - 但是下周将推出一项增强功能,即使是单个帐户选择器也会显示帐户案例,让用户有机会使用其他帐户登录。
希望有所帮助! - 马修,IAP工程负责人