通过Azure登录Google时出现错误

18

我的应用程序想要使用Google登录,所以我使用Azure 服务。我能够成功从Google登录并获取所有细节,但在Azure端出现以下错误:

Error Domain=com.Microsoft.WindowsAzureMobileServices.ErrorDomain Code=-1302 "Error: The id_token issuer is invalid." UserInfo={NSLocalizedDescription=Error: The id_token issuer is invalid.}

代码:

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




    }

我不知道这是令牌问题还是其他问题。


遇到了同样的问题 - 你能解决它吗? - user648931
@user648931 啊,问题还没有解决,如果你已经解决了,请告诉我。 - Sonali Pawar
@user648931,你解决了这个问题吗? - Sonali Pawar
你能在if语句的开头添加这行代码吗?print(idToken)并且将结果发布出来。 - Coder-256
请查看另一篇帖子https://dev59.com/5Zbfa4cB1Zd3GeqP1PjT,它似乎很有帮助。 - aman.sood
2个回答

1
我们得到的响应如下。我认为移动服务后端不喜欢发行者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"
}

1

我尝试了这个,但现在我遇到了这个错误:“Error Domain=com.Microsoft.MicrosoftAzureMobile.ErrorDomain Code=-1301 "The server returned an error." UserInfo={NSLocalizedDescription=The server returned an error." 我只想要客户端身份验证而不是服务器端。 - Sonali Pawar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接