# Basic authentication on API

**URL:** https://forum.mautic.org/t/basic-authentication-on-api/6725
**Category:** Product Support
**Created:** [December 2, 2016, 10:33pm UTC](https://forum.mautic.org/t/basic-authentication-on-api/6725 "2016-12-02T22:33:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![rnogueir](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rnogueir](https://forum.mautic.org/u/rnogueir)
#### Post date: [December 2, 2016, 10:33pm UTC](https://forum.mautic.org/t/basic-authentication-on-api/6725/1 "2016-12-02T22:33:05Z")

</div>

As far as I understood from the release notes, the 2.3.0 version allows Basic Authentication on the Mautic API. That’s good news for me, but… not sure how to make it work.  
  
  
  
My Mautic installation upgraded to 2.3.0 … done!  
  
Enabled HTTP basic auth on “API Configuration” … done!  
  
New API credentials created… well…  
  
  
  
There it starts. I couldn’t find a way to create credentials for the basic auth. If I try to run a “curl” command on the terminal, the response says:  
  
{“error”:“access\_denied”,“error\_description”:“OAuth2 authentication required”}  
  
  
  
Could anyone help me out with that?  
  
  
  
And just to avoid any misunderstanding, does “HTTP basic auth” mean that I can make this call:  
  
  
  
$ curl -u username:password [https://www.mautic-example.com/api/resources](https://www.mautic-example.com/api/resources)  
  
  
  
and it will work?

---

<div class="post-metadata">

### Author: ![rnogueir](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rnogueir](https://forum.mautic.org/u/rnogueir)
#### Post date: [December 2, 2016, 10:33pm UTC](https://forum.mautic.org/t/basic-authentication-on-api/6725/2 "2016-12-02T22:33:05Z")

</div>

As far as I understood from the release notes, the 2.3.0 version allows Basic Authentication on the Mautic API. That’s good news for me, but… not sure how to make it work.

My Mautic installation upgraded to 2.3.0 … done!  
Enabled HTTP basic auth on “API Configuration” … done!  
New API credentials created… well…

There it starts. I couldn’t find a way to create credentials for the basic auth. If I try to run a “curl” command on the terminal, the response says:  
{“error”:“access\_denied”,“error\_description”:“OAuth2 authentication required”}

Could anyone help me out with that?

And just to avoid any misunderstanding, does “HTTP basic auth” mean that I can make this call:

$ curl -u username:password [https://www.mautic-example.com/api/resources](https://www.mautic-example.com/api/resources)

and it will work?

---

<div class="post-metadata">

### Author: ![rnogueir](https://avatars.discourse-cdn.com/v4/letter/r/f08c70/32.png) [@rnogueir](https://forum.mautic.org/u/rnogueir)
#### Post date: [December 13, 2016, 3:55pm UTC](https://forum.mautic.org/t/basic-authentication-on-api/6725/3 "2016-12-13T15:55:36Z")

</div>

Answering myself: yes, the curl command above will work, but:

- the correct command form would be

```auto
curl -H "Authorization: Basic ##########" https://www.mautic-example.com/api/contacts 
```

- “###########” is a Base64 representation of the string “:”, where and can be your very login data for the Mautic application. The Base64 string can be generated on a Linux command line, e.g.

```auto
$ echo "myuser:12345" | base64 
```

The Base64 trick is mentioned on the documentation, but either I missed it entirely or it was added later. Whatever…

---

<div class="post-metadata">

### Author: ![punkael](https://avatars.discourse-cdn.com/v4/letter/p/db5fbb/32.png) [@punkael](https://forum.mautic.org/u/punkael)
#### Post date: [February 4, 2017, 6:07pm UTC](https://forum.mautic.org/t/basic-authentication-on-api/6725/4 "2017-02-04T18:07:42Z")

</div>

I was having the same problem. Thanks @rnogueir for the format. A couple things I ran into:

It seems that an incorrect username and password will also trigger the error:

```auto
{"error":"access_denied","error_description":"OAuth2 authentication required"}
```

Make sure you use -n with “echo” to prevent adding a newline to the encoding. This will render your username and password incorrect and you will get the same error as above. Like this works:

```auto
$ echo -n "myuser:12345" | base64 
```
