Integrate Google Contacts API into my Swift 3 app
<p>I am having a lot of trouble integrating Google contacts API into my app. Basically what I need is to request permission to the user and fetch all of the user's Gmail contacts(name and email). </p>

<p>For reference this is where the Google Contacts API is:
<a href="https://developers.google.com/google-apps/contacts/v3/" rel="nofollow">https://developers.google.com/google-apps/contacts/v3/</a></p>

<p>I already have Google SignIn implemented correctly and the user authenticated that way.</p>

<p>I am really struggling to put all the pieces together, here's what I have so far:</p>

<pre><code>  func retrieveContacts(){

        let clientID = "blabla-5blablablabla9gisc.apps.googleusercontent.com"
        let clientSecret = "blablablaDXEwmgilOXgVsQ"

  //How do I ask permission to the user to look at their contacts?
        let url2 = URL(string: "https://www.googleapis.com/auth/contacts.readonly")

        let user = GIDSignIn.sharedInstance().currentUser
        //let name = user?.profile.name
         let email = user?.profile.email

        var url = URL(string:"")

        if let aEmail = email{
         url = URL(string: "https://www.google.com/m8/feeds/contacts/\(aEmail)/full")
            print(email)
        }
let task = URLSession.shared.dataTask(with: url!) { data, response, error in
            guard error == nil else {
                print(error)
                return
            }
            guard let data = data else {
                print("Data is empty")
                return
            }

            print(response)
        }

        task.resume()
    }
</code></pre>

<p>Right now I am getting an Error Code:401 Not authorized, which is obvious because I am not really requesting permission to the user anywhere.</p>