ロジレス(LOGILESS)のWEB-APIでアクセストークンを更新する手続きを記録します。
VB.NET
Imports Newtonsoft.Json
Imports System.Net
Imports System.IO
Imports System.Text
'アクセストークン再取得
url = "https://app2.logiless.com/oauth2/token?client_id=" & client_id & "&client_secret=" & client_secret & "&refresh_token=" & refresh_token & "&grant_type=refresh_token"
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12'TLS 1.2 を有効にする
Using wc As New WebClient
wc.Headers.Add("ContentType", "application/json")
Using st As Stream = wc.OpenRead(url)
Using sr As StreamReader = New StreamReader(st, Encoding.UTF8)
jsonStr = sr.ReadToEnd()
End Using
End Using
End Using
jsonObj = JsonConvert.DeserializeObject(jsonStr) 'Json文字列をJson形式データに復元する
'新しい情報
accessToken = jsonObj("access_token").ToString.Replace("{", "").Replace("}", "")
expires_in = jsonObj("expires_in").ToString.Replace("{", "").Replace("}", "")
refresh_token = jsonObj("refresh_token").ToString.Replace("{", "").Replace("}", "")