user3306026
user3306026

Reputation: 122

how to do pivotaltracker oauth authentication using curl

I am new to curl. I'm trying basic authentication using curl with pivotal tracker

error:{"error":"Needs authentication credentials.","possible_fix":"Try basic auth, or include header X-TrackerToken.","code":"unauthenticated","kind":"error".
  1. here is simple code i used to authenticate:

     $ch = curl_init();
    $data = array('$token'=>'858e234da*****');
    // set URL and other appropriate options
    curl_setopt($ch, CURLOPT_URL, "https://www.pivotaltracker.com/services/v5/me");
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    // grab URL and pass it to the browser
    
     $response =curl_exec($ch);
     var_dump($response);
     // close cURL resource, and free up system resources
      curl_close($ch);
    
  2. how to authenticate my application with token as pivotal tracker support simple ouath authentication.

  3. i would like to explain steps of authentication

    a.)user enter user name and password.

    b.)then enter token of your profile.

    c.) now page is redirected your dashboard.

Upvotes: 3

Views: 445

Answers (1)

majidarif
majidarif

Reputation: 19975

Try basic auth, or include header X-TrackerToken.

Which seems to me is asking you to submit the token as a X-TrackerToken header.

You can try something like this, though I can't find the pivotaltracker documentation.

$ch = curl_init('https://www.pivotaltracker.com/services/v5/me'); 
// or just remove the customrequest too
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');                                                                                                                                     
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
    'X-TrackerToken: 858e234da*****'                                                                      
);                                                                                                                   

$result = curl_exec($ch);
curl_close($ch);

update

Found the documentation.

It shows something like:

export TOKEN='your Pivotal Tracker API token'
curl -X GET -H "X-TrackerToken: $TOKEN" "https://www.pivotaltracker.com/services/edge/stories/558"

Upvotes: 2

Related Questions