0
Dim WHTTP As Object
Set WHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")    

mainUrl = "https://googlesample.api.google/okta"
myuser = "myluckyuser"
mypass = "myluckypassword"

strAutheticate = "username=" & myuser & "& password=" & mypass
WHTTP.Open "POST", mainUrl, False
'WHTTP.setRequestHeader "apikey", "[Token]"
WHTTP.setRequestHeader "Content-Type", "application/json"
WHTTP.send strAutheticate

Dim response As String

??? How to I receive the token here ????

I am trying to invoke the API using REST and get the token.

so should return "access_token" : "blah134hao9u098-098-09";

2
  • Always helps to share a URL to the Help pages for the specific API you're trying to call. Commented Oct 17, 2024 at 22:36
  • whttp.responseText? you need to write a wait-loop though. Commented Oct 20, 2024 at 12:13

1 Answer 1

0
Dim tokenHTTP As Object
Set tokenHTTP = CreateObject("MSXML2.ServerXMLHTTP")
Dim tokenJSON As String
Dim tokenURL As String
Dim accessToken As String
tokenURL = "https://googlesample.api.google/okta"
tokenHTTP.Open "POST", tokenURL, True
tokenHTTP.setRequestHeader "Content-type", "application/json"
tokenHTTP.setRequestHeader "username", "myusername"
tokenHTTP.setRequestHeader "password", "mypassword"

tokenHTTP.send (tokenURL)
tokenJSON = tokenHTTP.responseText 
Sign up to request clarification or add additional context in comments.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.