title: AeroGearOAuth2 Swift Retrieve Google Contacts
body: <p>I am trying to make a contact management/social network application and am using the AeroGearOAuth2 after following a tutorial from the <a href="http://www.raywenderlich.com/99431/oauth-2-with-swift-tutorial" rel="nofollow">Ray Wenderlich website</a>. I have modified it to try and first authenticate the user, then using a closure in swift I am attempting to retrieve this user's contacts. I have used the google OAuth2 playground to play around with the scopes and GET url's but keep receiving the value of 'nil' on my inner response. I feel like I must jsut be forgetting something that is painfully obvious. I wasn't entirely sure how to attach the header of 'Gdata-version:3' so I winged that. This could be the problem. Here is my function to retrieve contacts:</p>
  
  <pre><code>    @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)")
          }
      })
  </code></pre>