It just implements my OWIN service with media (called access_token in the following) and updates the tokens. My understanding of this is that you can use different threads. So it depends on the thread you want to use when you set the access_token and refresh_token expiration times.
I will describe two streams A and B in the text (I suggest that you want to have stream B):
A) the expiration times of access_token and refresh_token are the same as the default of 1200 seconds or 20 minutes. This thread requires that your client first send client_id and client_secret with login information in order to get access_token, refresh_token and expiration_time. With refresh_token you can now get a new access_token within 20 minutes (or whatever you set AccessTokenExpireTimeSpan to OAuthAuthorizationServerOptions). Due to the fact that the expiration times for access_token and refresh_token are the same, your client is responsible for receiving a new access_token before the expiration date! For example. your client can send an updated POST request to the endpoint of your token with the body (note: you must use https in the production process)
grant_type=refresh_token&client_id=xxxxxx&refresh_token=xxxxxxxx-xxxx-xxxx-xxxx-xxxxx
to get a new token after, for example, 19 minutes, to prevent token skipping.
B) in this thread, you want to have a short-term expiration for your access_token and a long-term expiration for your refresh_token. Assume for testing purposes, you set the access_token parameter to expire after 10 seconds ( AccessTokenExpireTimeSpan = TimeSpan.FromSeconds(10) ) and refresh_token for up to 5 minutes. Now we are talking about the interesting part, setting the expiration time of refresh_token: you do this in your createAsync function in the SimpleRefreshTokenProvider class as follows:
var guid = Guid.NewGuid().ToString();
Now your client can send a POST call with refresh_token to the endpoint of your token when the access_token time is access_token . The main part of the call may look like this: grant_type=refresh_token&client_id=xxxxxx&refresh_token=xxxxxxxx-xxxx-xxxx-xxxx-xx
The important thing is that you can use this code not only in your CreateAsync function, but also in your Create function. Therefore, you should consider using your own function (e.g. CreateTokenInternal) for the above code. Here you can find implementations of different streams, including the refresh_token stream (but without setting the refresh_token update expiration time)
Below is one sample implementation of IAuthenticationTokenProvider on github (with setting refresh_token expiration time)
I'm sorry that I cannot help with additional materials than the OAuth specifications and Microsoft API documentation. I would post links here, but my reputation does not allow me to post more than two links ....
I hope this can help some others save time when trying to implement OAuth2.0 with refresh_token expiration time different from access_token expiration time. I could not find an implementation example on the Internet (other than the thinktecture link above), and it took me several hours to investigate until it worked for me.
New information: In my case, I have two different possibilities for receiving tokens. One of them is to get a valid access_token. There I have to send a POST call with the body of String in the format application / x-www-form-urlencoded with the following data
client_id=YOURCLIENTID&grant_type=password&username=YOURUSERNAME&password=YOURPASSWORD
Secondly, if the access_token is invalid, we can try refresh_token by sending a POST call with the body String in the format application/x-www-form-urlencoded with the following data grant_type=refresh_token&client_id=YOURCLIENTID&refresh_token=YOURREFRESHTOKENGUID