我們已經Google登錄我們的應用程序。我們在請求登錄時提供serverClientID。谷歌登錄服務器驗證碼無iOS?
我們得到user.serverAuthCode爲nil。
我們的要求是象下面這樣:
func googleLogin(){
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
let gid = GIDSignIn.sharedInstance()
if let path = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist") {
let myDict = NSDictionary(contentsOfFile: path)
gid?.serverClientID = "our servers cliet id as configured over firebase"
// This client id of our ios app we are getting from
// GoogleService-info.plist
gid?.clientID = myDict!.value(forKey: "CLIENT_ID") as! String
}
// gid?.serverClientID = "our_servers" // TODO: fetch from plist
gid?.scopes.append("https://www.googleapis.com/auth/gmail.readonly")
print("\nClient Id: \(gid!.clientID!) Server Client Id: \(gid!.serverClientID!)\n")
gid?.delegate = self
}
我們正在試圖讓serverAuthCode
如下:
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if (error == nil) {
// Perform any operations on signed in user here.
let auth = user.serverAuthCode
print(auth)
let fullName = user.profile.name
} else {
print("\(error.localizedDescription)")
}
}
但其serverAuthCode
爲空,我們不知道什麼可能已經錯了。
您的問題解決了沒有? –