2
發現使用谷歌客戶端庫用戶serverAuthCode所以我CAM experincrein問題是,我試圖使用客戶端身份驗證與谷歌API客戶端庫Azure中進行驗證。我能得到刷新,訪問和ID令牌,但serverAuthCode是nil
。我需要serverAuthCode才能創建HTTP請求來調用Azure身份驗證端點。在Azure SDK適用於iOS不支持谷歌的客戶端身份驗證(我在微軟談過多個工程師個個都建議不要使用他們的SDK進行身份驗證,因爲他們不支持它)。我不知道該做什麼,除了嘗試將我的頭圍繞在AWS上。任何幫助?不能在斯威夫特
而且,這裏是一段代碼
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()
它失敗並拋出異常說,它是尋找零每次。我已經隔離它來驗證這是什麼導致異常。
在此先感謝。