VBS Code to Get AccessToken

HowUTrade
Below is the VBS code to generate access token.
'On Error Resume Next

Dim Url
Dim HttpRequest
Dim Response
Dim ResponseStatus

Dim ApiKey
Dim ApiSecret
Dim RequestToken
Dim Checksum
Dim PostBody

'User Variables
Url = "https://api.kite.trade/session/token"
ApiKey = "xxxxxuyspkxxxq4r"
ApiSecret = "vklx4wsjxxxxxxxx1kn3dglkmt"
RequestToken = "eKq2zxxxxxxxxgXKcKOXgC9TJk"
Checksum = "a6a730fb02dcxxxxx48c7fd890ce054071a598d"
PostBody = "api_key=" & ApiKey & "&request_token=" & RequestToken & "&checksum=" & Checksum

'HTTP Request
Set HttpRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
HttpRequest.Open "POST", Url, False

'Headers
HttpRequest.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
HttpRequest.setRequestHeader "X-Kite-Version", "3"

'POST
HttpRequest.Send(PostBody)

'Response
Response = HttpRequest.ResponseText
ResponseStatus = HttpRequest.Status 'OK : 200

MsgBox "Response: " & Response & vbCrLf & vbCrLf & "Code: " & ResponseStatus & vbCrLf & "Error: " & Err.Description, 0 + 64, "Howutrade"
Set HttpRequest = Nothing
Tagged:
Sign In or Register to comment.