oauth 2.0 - AeroGearOAuth2 Swift Retrieve Google Contacts -
i trying make contact management/social network application , using aerogearoauth2 after following tutorial ray wenderlich website. have modified try , first authenticate user, using closure in swift attempting retrieve user's contacts. have used google oauth2 playground play around scopes , url's keep receiving value of 'nil' on inner response. feel must jsut forgetting painfully obvious. wasn't entirely sure how attach header of 'gdata-version:3' winged that. problem. here function retrieve contacts:
@ibaction func getgooglecontacts(sender: anyobject) { let googleconfig = googleconfig( clientid: ${my_client_id}, scopes:["https://www.googleapis.com/auth/userinfo.email","https://www.google.com/m8/feeds/contacts/default/full"]) let gdmodule = accountmanager.addgoogleaccount(googleconfig) self.http.authzmodule = gdmodule let headers = ["gdata-version ": "3.0"] let contactsurl:string = "https://www.google.com/m8/feeds/contacts/default/full" let emailurl:string = "https://www.googleapis.com/oauth2/v2/userinfo"; self.http.get(emailurl,completionhandler: {(response, error) in if (error != nil) { self.presentalert("error", message: "\(error!.localizeddescription) + \(response)") } else { let useremail: anyobject! = response!["email"]! self.http.get(contactsurl,parameters:headers, completionhandler: { (response2,error2) in if (error != nil) { self.presentalert("error",message:"\ (error2!.localizeddescription)" ) }else { println(response2) } }) self.presentalert("success", message: "successfully retrieved contact: + \(useremail)") } })
Comments
Post a Comment