# Help with API login og password setting

**URL:** https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231
**Category:** Questions about Thunkable X
**Created:** [January 20, 2021, 4:31pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231 "2021-01-20T16:31:58Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [January 20, 2021, 4:31pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/1 "2021-01-20T16:31:58Z")

</div>

Hi.  
I need a nice person that will help med with the setting of my API for Billy.  
I have the docs here [Billy API v2 Documentation | Billy.dk](https://www.billy.dk/api/#authentication)  
I am not sure where and how to enter my login and password. Can someone please help me out with the missing fields.  
Am I missing out something, please let me know.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/c/4cd1ba219119f6ba4d7b3cbe8d56947e2e2a053c.png)

---

<div class="post-metadata">

### Author: ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)
#### Post date: [January 20, 2021, 4:59pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/2 "2021-01-20T16:59:45Z")

</div>

Check out the node js section of code examples for the Billy api.

You will find

```auto
headers: {
                    'X-Access-Token': this.apiToken,
                    'Content-Type': 'application/json'
                },

```

This indicates the headers block should contain an object with 2 properties named X-Access-Token and Content-Type. Translating apis to Thunkable can be a challenge. Happy Thunking

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [January 20, 2021, 5:18pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/3 "2021-01-20T17:18:40Z")

</div>

Thanks for your fast reply. So nice of you.  
I tryed this but it dont work, What am I doing wrong? Thanks  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/7/373b96b69ba0eef8511bb317b43384ae17a1971e.png)

 ![Skaermbillede 2021-01-20 kl. 18.19.27](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/a/4a589cb8e0688fb22315a2704f3b06b524f2ec76.jpeg)

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [January 20, 2021, 5:53pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/5 "2021-01-20T17:53:46Z")

</div>

I now tryed this blocks  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/a/aaff248662dbefac60d8ca092740834cf761c714.png)  
Headers text is : {‘X-Access-Token’: f2361bb93689d15fd588e582e32c2xxxxxxxxxx,‘Content-Type’: ‘application/json’}

This blocks makes this error…

 ![Skaermbillede 2021-01-20 kl. 18.51.55](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/3/336c623395ca0482df8b1a7e94f5ac66b1970c5b.jpeg)

---

<div class="post-metadata">

### Author: ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)
#### Post date: [January 20, 2021, 6:14pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/6 "2021-01-20T18:14:42Z")

</div>

Put quotes around the token as well.

Also, quickly skimming the documentation, I’m not sure if you can get the user info without an email and password. You might need to switch to a different command

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [January 21, 2021, 9:33am UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/7 "2021-01-21T09:33:08Z")

</div>

@domhnallohanlon maybe you also can help with the blocks, please and thanks.

I have talked to their support and I just need the token. Is it JUST one place here “INSERT ACCESS TOKEN HERE” I need it or every place written $accesToken???

He send me this example below. The last example is how to make anew contact. But I really cant see the block in front of me for this example. Do I need all of the below code or what??  
Thanks a lot for your help.

//define a reusable class for sending requests to the Billy’s Billing API  
class BillyClient {  
private $accessToken;

```
public function __construct($accessToken) {
$this->accessToken = $accessToken;
}

public function request($method, $url, $body = null) {
    $headers = array("X-Access-Token: " . $this->accessToken);
    $c = curl_init("https://api.billysbilling.com/v2" . $url);
    curl_setopt($c, CURLOPT_CUSTOMREQUEST, $method);
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
    if ($body) {
        curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($body));
        $headers[] = "Content-Type: application/json");
    }
    curl_setopt($c, CURLOPT_HTTPHEADER, $headers);
    $res = curl_exec($c);
    $body = json_decode($res);
    $info = curl_getinfo($c);
    return (object)array(
        'status' => $info['http_code'],
        'body' => $body
    );
}

```

}

## $client = new BillyClient(“INSERT ACCESS TOKEN HERE”);

After this I can make a new contact with the following code:

//Create a contact  
$res = $client-\>request(“POST”, “/contacts”, array(  
‘contact’ =\> array(  
‘organizationId’ =\> $organizationId,  
‘name’ =\> “Arnold”,  
‘countryId’ =\> “DK”  
)  
));  
if ($res-\>status !== 200) {  
echo “Something went wrong:\n\n”;  
print\_r($res-\>body);  
exit;  
}

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [January 28, 2021, 3:47pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/8 "2021-01-28T15:47:37Z")

</div>

Hope you still wanna help. I found out I DONT need the mail and login. I just need the token.  
I get this message back

400 Bad Request
# Bad Request

Your browser sent a request that this server could not understand.  
The number of request header fields exceeds this server's limit.

* * *
Apache/2.4.18 (Ubuntu) Server at 172.17.0.11 Port 80

//-----------  
With this blocks ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/3/7319ea7949bbbc18d3d0b8510d76c5ec4f9f4803.png)

@domhnallohanlon hope you will give me a hint here. Thanks…  
The API docs is here [billy-api-v2-docs.md · GitHub](https://gist.github.com/cconrad/9489313#code-examples)

---

<div class="post-metadata">

### Author: ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)
#### Post date: [January 28, 2021, 4:07pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/9 "2021-01-28T16:07:50Z")

</div>

It looks like the header should be a JSON object with two properties X-Access-Token and Content-Type. You provided a string which is not formatted as JSON.

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [January 28, 2021, 4:09pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/10 "2021-01-28T16:09:24Z")

</div>

Smiling yes i am just trying something because it wont work like that either.  
You mean lige this right???  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/9/1953748298ec7120f5676b25281cd0d6c9ab9626.png)

---

<div class="post-metadata">

### Author: ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)
#### Post date: [January 28, 2021, 4:13pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/11 "2021-01-28T16:13:42Z")

</div>

Using blocks like this can eliminate problems with correctly formatting JSON.

![3e753eb16c96506860c78e8ced05252ca0a20fc2](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/0/c0acc96b2bd40c106ad8a4b141eeb629464d0286.png)

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [January 28, 2021, 4:20pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/12 "2021-01-28T16:20:49Z")

</div>

THAT make sence THANKS. 😁  
But now I get a nother error like this.

{“meta”:{“statusCode”:404,“success”:false},“errorMessage”:“Unknown resource `v2\/`.”,“errorCode”:“UNKNOWN\_RESOURCE”,“helpUrl”:“[https://billysbilling.com/api](https://billysbilling.com/api)”}

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/a/ca9bdf712d1d61c1b0802e38b28e921594676c02.png)

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [January 28, 2021, 4:27pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/13 "2021-01-28T16:27:42Z")

</div>

now I get this message. Like there is some authenticating missing  
{“meta”:{“statusCode”:401,“success”:false},“errorMessage”:“Invalid OAuth 2 access token.”,“errorCode”:“OAUTH\_INVALID\_ACCESS\_TOKEN”,“helpUrl”:“[https://billysbilling.com/api](https://billysbilling.com/api)”}

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:30pm UTC](https://community.thunkable.com/t/help-with-api-login-og-password-setting/1060231/14 "2024-11-08T13:30:38Z")

</div>


