Trying to access Confluence using Basic Authentication

Deleted user January 13, 2020

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

4 votes
Lukas Gotter _ Meetical
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
January 14, 2020

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! 

Stephane.arenas January 23, 2020

Hi @Lukas Gotter _ Meetical ,

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--------

xwlee January 23, 2020

Awesome, it works.

Like Lukas Gotter _ Meetical likes this
Lukas Gotter _ Meetical
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
January 24, 2020

@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? 

Stephane.arenas January 24, 2020

@Lukas Gotter _ Meetical , 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

Lukas Gotter _ Meetical
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
January 24, 2020

@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! 

Stephane.arenas January 27, 2020

@Lukas Gotter _ Meetical ,

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.

;)

Lukas Gotter _ Meetical
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
January 30, 2020

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

Matias_Reyes_Bettancourt April 30, 2020
2 votes
Ilya Turov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2020

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"

Deleted user January 13, 2020

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?

Ilya Turov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 14, 2020

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
AUG Leaders

Atlassian Community Events