Created
July 19, 2024 10:10
-
-
Save muhdkhokhar/f0ef734e3fd96060011b3323a45422a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' 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