# Authenticating in an API

**URL:** <https://discourse.processing.org/t/authenticating-in-an-api/7496>\
**Category:** Libraries\
**Created:** [January 14, 2019, 8:59am UTC](https://discourse.processing.org/t/authenticating-in-an-api/7496 "2019-01-14T08:59:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bavo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bavo/32/3240_2.png) [@Bavo](https://discourse.processing.org/u/Bavo)\
**Post date:** [January 14, 2019, 8:59am UTC](https://discourse.processing.org/t/authenticating-in-an-api/7496/1 "2019-01-14T08:59:22Z")

</div>

Hi all

I’m stuck trying to authenticate, the documentation only shows an example in cURL and the examples available haven’t gotten me anywhere.

This is the API documentation: [https://api.freshservice.com/v2/#authentication](https://api.freshservice.com/v2/#authentication)  
Here is a range of samples in different languages: [https://github.com/freshdesk/fresh-samples](https://github.com/freshdesk/fresh-samples)

I’ve tried a whole bunch of things but I’m fairly new to this and could really use some help.  
I think I’m on the right track using the http requests library, but I haven’t really gotten anywhere.

```auto
import http.requests.*;

void setup() {
  size(1280, 720);
  GetRequest get = new GetRequest("https://" + "bruzz.freshservice.com/api/v2/tickets/1068");
  get.addHeader("Content-Type", "application/json");
  get.addHeader("apikey", "InsertApiKeyHere"); 
  get.send();
  JSONObject response = parseJSONObject(get.getContent());
  println("status: " + response.getString("ticket"));
}

```

The above attempt returns

```auto
Jan 14, 2019 9:34:28 AM org.apache.http.impl.client.DefaultRequestDirector handleResponse
WARNING: Authentication error: Unable to respond to any of these challenges: {}
status: null

```

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 14, 2019, 10:50am UTC](https://discourse.processing.org/t/authenticating-in-an-api/7496/2 "2019-01-14T10:50:27Z")

</div>

i not say it is wrong way, but i look at 2 examples,  
and they work with

```auto
  json = loadJSONObject(url+query+"&page="+page+beginDate+endDate+"&api-key="+apiKey);

```

or

```auto
loadJSON(url,gotData); // callback version

```

so pls check on  
[https://processing.org/reference/loadJSONObject\_.html](https://processing.org/reference/loadJSONObject_.html)

---

<div class="post-metadata">

**Author:** ![Bavo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bavo/32/3240_2.png) [@Bavo](https://discourse.processing.org/u/Bavo)\
**Post date:** [January 14, 2019, 11:01am UTC](https://discourse.processing.org/t/authenticating-in-an-api/7496/3 "2019-01-14T11:01:45Z")

</div>

Hi! Thanks for the reply. I’ve tried that method but including the apiKey in the url doesn’t seem to work (won’t work when I try it in a browser either, unless I’m already logged in.)

---

<div class="post-metadata">

**Author:** ![Bavo](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bavo/32/3240_2.png) [@Bavo](https://discourse.processing.org/u/Bavo)\
**Post date:** [January 16, 2019, 12:36pm UTC](https://discourse.processing.org/t/authenticating-in-an-api/7496/4 "2019-01-16T12:36:36Z")

</div>

Sorry to bump this, Are there any other suggestions?

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [January 16, 2019, 12:49pm UTC](https://discourse.processing.org/t/authenticating-in-an-api/7496/5 "2019-01-16T12:49:49Z")

</div>

no,

> [@Bavo](#):
>
> I’ve tried that method but including the apiKey in the url doesn’t seem to work (won’t work when I try it in a browser either, unless I’m already logged in.)

> **[Service Desk API for Developers | Freshservice](https://api.freshservice.com/v2/#changelog)**
>
> If you are developer who wants to build applications on top of our service desk platform, the Freshservice APIs is all you need.

> Authentication

### How does it work? Who can access my helpdesk? Can everybody see my data?

Before you can set the priority of a ticket or change a customer’s name or use any of the APIs listed above, you need to “authenticate your ID” or “log in” in the same way you log in to your helpdesk’s web portal.

so possibly:

> as a security measure you need to be  
> LOGIN  
> just API alone might not work

but that can only be answered  
[https://support.freshservice.com/support/discussions](https://support.freshservice.com/support/discussions)

or you have any reason to believe that it is a processing issue?
