It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Trying to access Confluence using Basic Authentication

How can I activate Basic Authentication on my Jira instance? 

I am getting an error response: Basic auth with password is not allowed on this instance

2 answers

Hi Enido,

Basic Auth still works on Confluence Cloud, but you have to use an Atlassian API Token as password and your Atlassian Id email as username. 

You will get the error "Basic auth with password is not allowed on this instance" also if you provide a wrong username/password. This should be fixed by Atlassian to avoid confusion.

So try again with a valid Atlassian Id + API token. 

Example:

GET https://<your-instance-name>.atlassian.net/wiki/rest/api/content/123123
Content-Type: application/json
Accept: application/json
Authorization: Basic yourBase64EncodedUsernameColonPassword

Good luck! 

Hi @Lukas_Gotter ,

On my side If I do a test with Insomnia :

It's work fine 

But If I do the same test in VBA with MSXML2.XMLHTTP60 and I setRequestHeader "Authorization", "Basic " & sEncbase64Auth

I alway have an empty response while I use the same credential

Do you have any idea from the reason of this specific response on VBA ?

 

Below my VBA code:

Private Function UserPassBase64(text As String) As String
Dim objXML As MSXML2.DOMDocument60
Dim objNode As MSXML2.IXMLDOMElement
Dim arrData() As Byte

arrData = StrConv(text, vbFromUnicode)

Set objXML = New MSXML2.DOMDocument60
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData

UserPassBase64 = objNode.text

End Function

 

Sub test()
Dim JiraService As New MSXML2.XMLHTTP60
Dim sUsername As Variant
Dim sPassword As Variant
Dim sRestAntwort As Variant

Dim sStatus As Variant
Dim sEncbase64Auth As Variant

sUsername = "" 'Atlassian e-mail of your account
sPassword = "" 'Token generated by  https://id.atlassian.com/manage/api-tokens

sEncbase64Auth = UserPassBase64(sUsername & ":" & sPassword)


With JiraService
.Open "GET", "https://xxxxxxx.atlassian.net/rest/api/3/project", False
.setRequestHeader "Content-Type", "application/json;charset=UTF-8"

.setRequestHeader "Accept", "application/json"
.setRequestHeader "Authorization", "Basic " & sEncbase64Auth
.send
sRestAntwort = .responseText
sStatus = .Status & " | " & .statusText
Debug.Print "--------" & Now & "--------"
Debug.Print sRestAntwort
Debug.Print sStatus
Debug.Print "--------" & Now & "--------"
End With
End Sub

 

Result:

--------23/01/2020 16:52:02--------
[]
200 |
--------23/01/2020 16:52:02--------

Awesome, it works.

Like Lukas_Gotter likes this

@Stephane_arenas - interesting, because from what I understand in your VB code (wow, long time no see VB! ;)) - you get an empty json array as response. Are you sure you have the rights to browse projects? can you try another endpoint? can you reproduce the request with curl or something similar? 

@Lukas_Gotter , as I say on my first post with the same credential it work fine with Insomnia (Postman like). If I try curl -D- -u xxxx:yyyyyyy -X POST -H "Content-Type: application/json" https://zzzzzz.atlassian.net/rest/api/3/project . it works fine also.

If I don't use UserPassBase64 and I tried to set directly .setRequestHeader "Authorization", "Basic " & sUsername & ":" & sPassword, I have got 403 error (Basic auth with password is not allowed on this instance)

But if  I change keep UserPassBase64 and I add on or tow mors characters to my e-mail adress or my token I alway have an empty json and http response to 200 even if my credential is not good.

So I think that we have an issu with credential but I don't uderstand what is the mistake

@Stephane_arenas well then it seems your base64 function is not working correctly. Try with a test user and set the user:password as base64 encoded string you get from https://www.base64encode.org/ - if that works, it's your function and I assume you will find a good one online for VB. - good luck! 

@Lukas_Gotter ,

https://www.base64encode.org/  look like give the same result as my base64 function, but  in my base64 function I have a LF car(10) after 72 charater.

If I tried to used directly the https://www.base64encode.org/ result (without LF) I had a 403 http Error "Basic auth with password is not allowed on this instance"

But we were on the good way to focus on base64 function

When I look timeline tab on Insomnia I notice that I don't have the same encryption for mycredential, and if I use "Insomnia credential encryption" in my vba code it's work fine.

So I worked to undestand why I had a bad encryption with my base64 function,

And I fine the solution....... I'm stupid and I don't know how to realize a simple copy paste of my API key.

After some check, I discovered that on my VBA version I had 4 extract characters in the middle of my API Token. (Perhaps I tried to start to write on ohters windows withour click on it)

I apologize for the time you spent to help a so stupid guy as me.

;)

No worries, good to hear I'm glad if I could help. Many greetings, Lukas

Hello, basic authentication has been deprecated recently:

https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/

"update your app or integration to use API tokens, OAuth, or Atlassian Connect"

Hi, thank you for your quick response. 

I created an api token, concatenated it with the email and encoded it to base64 and added as a header field. Can I still use this way to access Confluence?

I'm not 100% sure, but as far as I understand, token is created for the account to access any cloud products it has access to, so yes

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What project did you transition or start on Confluence with the shift to remote work?

It’s been great to hear from fellow users over the last few weeks about the best tips and fun moments you’ve had working on Confluence since the transition to working remote. I’d love to keep the c...

109 views 3 7
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you