在我的应用程序中,我想使用谷歌登录,因此我使用Azure服务。从Google,我可以成功登录并获取所有详细信息,但Azure端出现以下错误:
Domain=com.Microsoft.WindowsAzureMobileServices.ErrorDomain错误代码=-1302“错误: id_token颁发者无效。”UserInfo={NSLocalizedDescription=Error: id_token颁发者无效。}
代码:
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
}
我不知道这是代币发行还是别的什么。
发布于 2017-01-12 01:39:41
我们得到的响应如下所示。我认为移动服务后台不喜欢发布者id:"https://accounts.google.com“。它接受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"
}
发布于 2017-04-17 11:56:27
对于谷歌来说,你需要id_token和authorization_code:
let payload: [String: String] = ["id_token": user.authentication.idToken, "authorization_code": user.serverAuthCode]
client.loginWithProvider("google", token: payload) { (user, error) in
// ...
}
https://stackoverflow.com/questions/39410491
复制相似问题