ios - 在 Swift 中找不到使用 Google 客户端库的用户的 serverAuthCode
<p><p>所以我遇到的问题是我正在尝试使用带有 Google API 客户端库的客户端身份验证对 Azure 进行身份验证。我可以获得刷新、访问和 IDtoken ,但 serverAuthCode 是 <code>nil</code>。我需要 serverAuthCode 来创建调用 Azure 身份验证端点的 HTTP 请求。适用于 iOS 的 Azure SDK 不支持 Google 的客户端身份验证(我曾与 Microsoft 的多名工程师交谈过,他们都建议不要使用他们的 SDK 进行身份验证,因为他们不支持它)。我不知道该怎么做,除了试着绕着 AWS 转。有什么帮助吗?</p>
<p>另外,这是一段代码</p>
<pre><code>func viewController(vc : UIViewController, finishedWithAuth authResult : GTMOAuth2Authentication, error : NSError?) {
let azureGoogleServerAuthToken = authResult.userData.serverAuthCode
let azureGoogleIdToken = authResult.parameters["id_token"] as! String
let request = NSMutableURLRequest(URL: NSURL(string: "https://retip-ios.azurewebsites.net/.auth/login/google")!)
request.HTTPMethod = "POST"
let postString = "authorization_code=\(azureGoogleServerAuthToken)&id_token=\(azureGoogleIdToken)"
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) { data, response, error in
guard error == nil && data != nil else { // check for fundamental networking error
print("error=\(error)")
return
}
if let httpStatus = response as? NSHTTPURLResponse where httpStatus.statusCode != 200 { // check for http errors
print("statusCode should be 200, but is \(httpStatus.statusCode)")
print("response = \(response)")
}
let responseString = NSString(data: data!, encoding: NSUTF8StringEncoding)
print("responseString = \(responseString)")
}
task.resume()
</code></pre>
<p>它失败了,但有一个异常说它每次都找到 nil。我已将其隔离出来以验证这是导致异常的原因。</p>
<p>提前致谢。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>在直接与 Azure 支持人员交谈并与他们一起工作了一个多星期以找到解决方案后,似乎他们的文档在此问题上故意含糊其辞,因为他们不支持通过 Google 进行客户端身份验证。任何解决方案都需要自定义构建,这意味着通过 Azure SDK 无法实现。</p></p>
<p style="font-size: 20px;">关于ios - 在 Swift 中找不到使用 Google 客户端库的用户的 serverAuthCode,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/39048787/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/39048787/
</a>
</p>
页:
[1]