1

I'm trying to use this api request in my angular application

    curl https://{subdomain}.zendesk.com/api/v2/help_center/articles.json \
    -v -u {email_address}:{password}

This does work in terminal but I honestly just don't know how to format that for the $http service in angular. Still new. Thank you for any help!

Edit: It is a GET request

2
  • Do you know what kind of authentication is performed while requesting this URL with curl? Commented Dec 18, 2015 at 21:28
  • I think they can use the email:password approach, API Token, or Oauth Token. developer.zendesk.com/rest_api/docs/core/… Commented Dec 18, 2015 at 22:14

1 Answer 1

1

It depends on the type of authentication that you have or want to perform to access this API. The simplest is probably BASIC authentication.

For a BASIC authentication, as per rfc2617, you have to provide a valid BASIC authorization header in your request.

This can be performed by setting this header once for all like this with AngularJS:

$http.defaults.headers.common.Authorization = 'Basic ' + basic-credentials;

Where basic-credentials is the base64 encoded user:password string.

So subsequent requests will use this header and will be authorized by this API.

If you haven't already read it, you can take a look at AngularJS $http documentation which describes how to set HTTP headers and use the $http service. It also provides an example of BASIC authentication.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.