Ron Anderson
New Member
Hi, I have a main Excel application which downloads data from a web server using VBA and a REST API. Currently I need to RENEW the token daily. I've built a test application to REFRESH the token because I don't want to renew the token daily. The test app only works after I've ran the main apps daily renewal. Furthermore, The test app will only work if the main app is in the background. Using the test app by itself will not work.
I'd really appreciate it if someone can look at the code and offer suggestions to get the test app working without needing the main app to be open. Here's the code:-
>>> use code - tags <<<
I've checked and double checked my credential and they are correct.
Thanks, in anticipation, Ron
I'd really appreciate it if someone can look at the code and offer suggestions to get the test app working without needing the main app to be open. Here's the code:-
>>> use code - tags <<<
Code:
Sub RefreshToken()
Dim hReq As Object, json As Dictionary
Dim sht As Worksheet
Dim strUrl As String
Set sht = Sheet1
strUrl = Cells(1, 5).value 'Variable text held in this cell
Set hReq = CreateObject("MSXML2.XMLHTTP")
With hReq
.Open "GET", strUrl, False
.SetRequestHeader "Authorization", "<Basic Base64Encode>"
.SetRequestHeader "Content_Type", "application/x-www-form-urlencoded"
.SetRequestHeader "grant_type", "refresh_token"
.SetRequestHeader "refresh_token", “<MyRefreshToken>”
.Send
End With
Response = hReq.ResponseText
‘//Do other things here
End Sub
I've checked and double checked my credential and they are correct.
Thanks, in anticipation, Ron
Last edited by a moderator: