0

PROBLEM: I cannot authorize my connection to ASANA.

Breaking my code to the simplist bits. I used: http://onlinecurl.com/ to mimic what I see at

https://asana.com/developers/documentation/getting-started/authentication#sts=API%20Keys

This is my command.

curl --user 'NWE2MDJqUloubnpCUjh0d3gxVmYydW5BeFlJUER0Smw6' https://app.asana.com/api/1.0/users/me

Original : 5a602jRZ.nzBR8twx1Vf2unAxYIPDtJl

I even used https://www.base64encode.org/ to make sure my base64 was correct, which it is.

Response Header

1 HTTP/1.1 401 Unauthorized
2 Server: nginx
3 Date: Sat, 25 Oct 2014 17:58:23 GMT
4 Content-Type: application/json; charset=UTF-8
5 Transfer-Encoding: chunked
6 Connection: keep-alive
7 X-Asana-Content-String-Length: 41
8 Pragma: no-cache
9 Set-Cookie: TooBusyRedirectCount=0
10 Cache-Control: no-store
11 X-Asana-Preferred-Release-Revision: 20141024_201328_7ebcb21240775f3d5e6038b42ade419530485b76
12 X-Robots-Tag: none

Response Body

1{"errors":[{"message":"Not Authorized"}]}

How can I connect to the service with my Authorization???

Since writing this I have reset my aPIKEY

Justin
  • 3,418
  • 3
  • 27
  • 37
Ali
  • 99
  • 2
  • 12

2 Answers2

1

You do not need to base64-encode the username yourself, curl will do that for you. Also, please be careful of sharing your API key on public forums; these are sensitive credentials that should be treated like usernames and passwords! If that is a real API key I advise you reset it immediately (which you can do through the UI where you discovered it).

Greg S
  • 2,079
  • 1
  • 11
  • 10
  • thanks I reset it already. I reset it as soon as I ... before I even posted this link. I didn't want any one to answer this post saying ,"it's becuase your key is 'XXXXXX'" – Ali Oct 28 '14 at 14:42
0

There needs to be a content Header Here is what I did in Google Scripts.

In the site : http://onlinecurl.com/ we would need an extra option in headers for content-type

function getTasksFromAsana() {
  api_key = "XXXX";
  workspace_id = "WORKSPACE-ID";

  // set up HTTPS connection
  uri = "https://app.asana.com/api/1.0/users/me";

  // set up the request
  req={};
  req = {
    "headers":{ 'content-type': 'application/json','authorization': 'Basic ' + api_key }
  }



  Logger.log('Get Tasks Asana');

  var response = UrlFetchApp.fetch(uri,req);

  Logger.log(response.getContentText());
}
Ali
  • 99
  • 2
  • 12