Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save muhdkhokhar/f0ef734e3fd96060011b3323a45422a5 to your computer and use it in GitHub Desktop.
Save muhdkhokhar/f0ef734e3fd96060011b3323a45422a5 to your computer and use it in GitHub Desktop.
' Add the necessary references to your VBA project:
' - Microsoft XML, v6.0
' - Microsoft Scripting Runtime
Public Function Base64Encode(text As String) As String
Dim arrData() As Byte
arrData = StrConv(text, vbFromUnicode)
Dim objXML As Object
Set objXML = CreateObject("MSXML2.DOMDocument.6.0")
Dim objNode As Object
Set objNode = objXML.createElement("b64")
objNode.DataType = "bin.base64"
objNode.nodeTypedValue = arrData
Base64Encode = objNode.text
Set objNode = Nothing
Set objXML = Nothing
End Function
Public Function GetOAuth2TokenWithPassword(clientId As String, clientSecret As String, tokenUrl As String, username As String, password As String) As String
Dim http As Object
Dim json As Object
Dim jsonConverter As New JsonConverter
Dim payload As String
Dim responseText As String
Dim token As String
Dim authorizationHeader As String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment