Ios 通过Azure的Google登录错误
在我的应用程序中,我想使用谷歌登录,因此我正在使用Azure服务。从Google,我可以成功登录并获取所有详细信息,但Azure端出现以下错误: Error Domain=com.Microsoft.WindowsAzureMobileServices.ErrorDomain 代码=-1302“错误:id_令牌颁发者无效。” UserInfo={NSLocalizedDescription=错误:id\u令牌颁发者为 无效。} 代码:Ios 通过Azure的Google登录错误,ios,swift,azure,azure-mobile-services,Ios,Swift,Azure,Azure Mobile Services,在我的应用程序中,我想使用谷歌登录,因此我正在使用Azure服务。从Google,我可以成功登录并获取所有详细信息,但Azure端出现以下错误: Error Domain=com.Microsoft.WindowsAzureMobileServices.ErrorDomain 代码=-1302“错误:id_令牌颁发者无效。” UserInfo={NSLocalizedDescription=错误:id\u令牌颁发者为 无效。} 代码: if (user.authentication != nil
if (user.authentication != nil)
{
let delegate = UIApplication.sharedApplication().delegate as? AppDelegate
let client = delegate!.client!;
// let nextViewController = self.storyboard?.instantiateViewControllerWithIdentifier("SWRevealViewController") as! SWRevealViewController
// self.presentViewController(nextViewController, animated: true, completion: nil)
let payload: [String: String] = ["id_token": idToken]
client.loginWithProvider("google", token: payload, completion: { (user, error) in
if error != nil{
//here i am getting the above mentioned error
print(error)
}
if user != nil{
print(user)
print("Google Login Sucess")
self.call(false, email: email, firstName: firstName, lastName: lastName, id: googleId, token: idToken,imageUrl: imageUrl.absoluteString)
}
})
}
override func viewDidLoad()
{
super.viewDidLoad();
GIDSignIn.sharedInstance().signOut()
GIDSignIn.sharedInstance().scopes.append("https://www.googleapis.com/auth/plus.login");
GIDSignIn.sharedInstance().clientID = "XXXXXXXX";
GIDSignIn.sharedInstance().serverClientID = "XXXXXXXXX"
GIDSignIn.sharedInstance().uiDelegate = self
}
我不知道这是代币问题还是其他问题。我们得到的答复如下。我认为移动服务后端不喜欢发卡机构id:“”。它接受accounts.google.com
{
"iss": "https://accounts.google.com",
"at_hash": "bGW4JYlbzO64NGLInOpKgg",
"aud": "XXXXXX-XXXXXXX",
"sub": "XXXXXXXXXX",
"email_verified": "true",
"azp": "XXXXXX-XXXXXXXXXXX",
"hd": "techmorphosis.com",
"email": "anuj@techmorphosis.com",
"iat": "1477398958",
"exp": "1477402558",
"name": "Anuj Mody",
"given_name": "Anuj",
"family_name": "Mody",
"locale": "en",
"alg": "RS256",
"kid": "XXXXXXXXXXXX"
}
对于google,您需要id_令牌和授权_代码:
let payload: [String: String] = ["id_token": user.authentication.idToken, "authorization_code": user.serverAuthCode]
client.loginWithProvider("google", token: payload) { (user, error) in
// ...
}
Ref:遇到同样的问题-您能解决吗?@user648931不,问题仍然没有解决,如果您已经解决了,请务必告诉我。@user648931您解决了问题吗?您能在if语句的开头添加这个吗?:
print(idToken)
并发布结果。检查另一篇看起来有用的帖子。我尝试了这个方法,但现在我收到了这个错误“error Domain=com.Microsoft.MicrosoftAzureMobile.ErrorDomain code=-1301”服务器返回了一个错误。“UserInfo={NSLocalizedDescription=服务器返回了一个错误。”另外,我只需要客户端身份验证,而不是服务器端身份验证。