I'm using the Box SDK with VB.NET on VS2017. I'm able to obtain an authorization code and retrieve access and refresh tokens. All works fine for an hour as expected and when the access token expires, the refresh token doesn't refresh both itself and the access token. Here's my code that I use as a first time setup to obtain the access and refresh tokens with my auth code.
Dim config = New BoxConfig("XXXXXX", "XXXXXXX", New Uri("https://localhost"))
Dim client = New BoxClient(config)
Dim auth As OAuthSession = Await client.Auth.AuthenticateAsync(XXXXXX)
strAccessToken = auth.AccessToken.ToString
strRefreshToken = auth.RefreshToken.ToString
My.Settings.AccessToken = auth.AccessToken
My.Settings.RefreshToken = auth.RefreshToken
My.Settings.Save()
And here's my code for each subsequent event. The strAccessToken and strRefreshToken are stored as shown above.
Dim auth = New OAuthSession(strAccessToken, strRefreshToken, 3600, "bearer")
Dim config = New BoxConfig("XXXXXX", "XXXXX", New Uri("https://localhost"))
Dim client = New BoxClient(config, auth)
My.Settings.AccessToken = auth.AccessToken
My.Settings.RefreshToken = auth.RefreshToken
But as soon as I execute this line:
Dim items As BoxCollection(Of BoxItem) = Await client.FoldersManager.GetFolderItemsAsync("0", 500)
I get a badrequest {400} Message "Exception of type 'Box.V2.Exceptions.BoxSessionInvalidatedException' was thrown." String.
Am I wrongfully expecting that the SDK is supposed to handle the refresh or am I just going about this incorrectly? Thanks in advance for any help!