适用于 iOS 后端的 Google 登录 API 凭据 (Swift)



我已经在我的iOS应用程序中实现了谷歌登录,我想将用户的ID令牌发送到我的服务器进行验证。我已通过 Google Cloud Platform Console 创建了适用于 iOS 的客户端 ID,尽管我在应用和服务器上使用相同的客户端 ID,但当我向服务器发送请求时,服务器会引发 500 错误。我应该使用另一种客户端 ID 吗?

*
Error code 500 is an internal server error. so check issues using postman.
@IBAction func GoogleLoginBtn(_ sender: Any) {
GIDSignIn.sharedInstance().signIn()
}
func sign(_ signIn: GIDSignIn!, didDisconnectWith user:GIDGoogleUser!,withError error: Error!) {
print(error)
return
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if (error == nil) {
// Perform any operations on signed in user here.
id = user.userID
Name = user.profile.name
Email = user.profile.email
url = String(describing: user.profile.imageURL(withDimension: (400))!)
}
}
In-app delegate:-
GIDSignIn.sharedInstance().clientID = "76lp4.apps.googleusercontent.com"
// paste ur reverse client id here
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
print("UIApplicationOpenURLOptionsKey.sourceApplication.rawValue: (UIApplicationOpenURLOptionsKey.sourceApplication.rawValue)")
print("UIApplicationOpenURLOptionsKey.annotation.rawValue: (UIApplicationOpenURLOptionsKey.annotation.rawValue)")
return GIDSignIn.sharedInstance().handle(url as URL?,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String?,
annotation: options[UIApplicationOpenURLOptionsKey.annotation])
}

*

最新更新