So the problem that I cam experincrein is that I am trying to authenticate with Azure using client side auth with the Google API Client Library. I can get the refresh, access and ID tokens but the serverAuthCode is nil. I need the serverAuthCode in order to create the HTTP request to call the Azure authentication endpoint. The Azure SDK for iOS doesn't support client side authentication for Google (I've spoken to multiple engineers at Microsoft all of them have suggested not using their SDK for authentication because they don't support it). I don't know what to do besides try wrapping my head around AWS. Any Help?
Also, here is the piece of 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()
It fails with an exception saying that it is finding nil every time. I have isolated it out to verify that this is what is causing the exception.
Thanks in advance.
After speaking with Azure support directly and working with them for over a week to find a solution, it appears as if their documentation is purposely vague on the issue because they do not support client side authentication with Google. Any solution would need to be custom built, meaning that this is not achievable through the Azure SDK.