I am trying to connect to google api.
This works fine in my terminal, there I do:
curl https://www.googleapis.com/tasks/v1/users/@me/lists --header "Authorization: Bearer myAccessCode"
.
This works great, but now I want to do it inside the c program.
For this, I:
CURL *curl; char *header = "Authorization: Bearer myAccessCode"; struct curl_slist *headers = NULL; headers = curl_slist_append(headers, header); curl = curl_easy_init(); char *response = NULL; curl_easy_setopt(curl, CURLOPT_URL, "https://www.googleapis.com/tasks/v1/users/@me/lists"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_HTTPGET, 1); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, httpsCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response); curl_easy_perform(curl); curl_easy_cleanup(curl);
But here I just get a message that a login is required. I have no idea what I'm doing wrong, is there someone who sees my failure?
source share