Skip to content

Instantly share code, notes, and snippets.

@theredstapler
Created January 28, 2016 13:19
Show Gist options
  • Save theredstapler/45e777fc468891699e38 to your computer and use it in GitHub Desktop.
Save theredstapler/45e777fc468891699e38 to your computer and use it in GitHub Desktop.
Sub test()
Call testAuthen
End Sub
Private Function UserPassBase64() As String
Dim objXML As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMElement
Dim arrData() As Byte
arrData = StrConv("username:password", vbFromUnicode)
Set objXML = New MSXML2.DOMDocument
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData
UserPassBase64 = objNode.Text
End Function
Public Function testAuthen()
Dim JiraService As New MSXML2.XMLHTTP60
With JiraService
.Open "GET", "https://jira.atlassian.com/rest/api/latest/issue/JRA-9.json", False
.SetRequestHeader "Content-Type", "application/json"
.SetRequestHeader "Accept", "application/json"
.SetRequestHeader "Authorization", "Basic " & UserPassBase64
.Send ""
MsgBox .Status
If .Status = "401" Then
MsgBox "Not authorized or invalid username/password"
Else
MsgBox "Correct credential!!"
End If
End With
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment