1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

OAuth2.0 VB.NET アクセストークンの更新

Last updated at Posted at 2021-07-09

ロジレス(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("}", "")

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?