1

I am new to clockify API integration. I want to retrieve all the workspaces. I am requesting 'https://api.clockify.me/api/workspaces/' this API & sending 'X-Api-Key' in the header. when I am requesting this API from postman I got (success response) all data as response. but when I am requesting this API from the browser I am getting '{"message": "Full authentication is required to access this resource", "code":1000}' this error response. what is wrong with it I don't understand.

Curl Request:

curl 'https://api.clockify.me/api/workspaces/' \
-H 'Accept: application/json, text/plain, */*' \
-H 'Referer: http://localhost:4200/' \
-H 'Origin: http://localhost:4200' \
-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.80 Safari/537.36' \
-H 'X-Api-Key: {API-Key}' --compressed

please help. Thank you in advance.

ldeld
  • 546
  • 3
  • 18
lakhan
  • 255
  • 7
  • 14
  • There must be some problem with the way, you created and called the http request in angular. Can you post your http method in angular, that shows how you are setting the header and calling it? – KiraAG Jan 10 '19 at 10:36
  • getCall(apiUrl) { const httpHeaders = new HttpHeaders ({ 'X-Api-Key': 'XC3bELB5h069yb8I' }); return this.http.get(this.clokifyUrl + apiUrl, { headers: httpHeaders }) .pipe( map( data => { return data; }), catchError( error => { return throwError( 'Something went wrong!' ) }) ) } – lakhan Jan 11 '19 at 05:28

1 Answers1

0

this error occurs because your Referer is localhost -H 'Referer: http://localhost:4200/' and clockify API not support localhost request.

if you have to run clockify API in to your localhost to following this step:

  1. set up Virtual Host locally i have used XAMPP so I can attach Virtual Host set up locally link: https://ourcodeworld.com/articles/read/302/how-to-setup-a-virtual-host-locally-with-xampp-in-ubuntu

  2. make a build of your project using ng build command

  3. then configure your project in hosts using this command sudo gedit /etc/hosts
  4. then set up your directory path in /opt/lampp/etc/extra/httpd-vhosts.conf file

after that, you can use clockify API locally

I hope you understand correctly what I have explained here