javascript - REST API basic authentication of third party -
i use teamwork project management tool. trying create web app using rest api given teamwork. requires authentication. have read teamwork documentation , have said
authentication
authentication managed using http authentication (only "basic" supported right now). every request must include authorization http header. use api token username, , "x" (or otherwise bogus text) password (only api token used authenticating api requests).
example curl:
curl -h 'accept: application/json' -h 'content-type: application/json' \ -u apikey0123456789:xxx -d '{"request": {"name": "some value"}}' https://yours.teamwork.com
i looked online tutorial , wrote following code
public function portallogin() { //curl // phpinfo(); //curl enabled $channel = curl_init(); //options curl_setopt($channel, curlopt_url, "http://projects.abounde.com/projects.json?status=late"); curl_setopt($channel, curlopt_httpheader, array("authoritation:basic".base64_encode("secretapicode:xxx"))); echo curl_exec($channel); //return 1 curl_close($channel); }
this returns 1. not know means. not know if doing right thing. teamwork api protected authentication.
http://projects.abounde.com/projects.json
my end goal give different users different username , password enter , system find secret key database , load project list particular user.
public function portallogin() { //curl // phpinfo(); $username = "night720elvis"; $password = "xxx"; $channel = curl_init(); //options curl_setopt($channel, curlopt_url, "http://projects.abounde.com/projects.json?status=late"); //curl_setopt($channel, curlopt_httpheader, array("authoritation:basic".base64_encode("night720elvis:xxx"))); curl_setopt($channel, curlopt_httpheader, array( "authorization: basic " . base64_encode($username . ":" . $password) )); echo curl_exec($channel); curl_close($channel); }
this authenticates
Comments
Post a Comment