public ViewResult RefreshToken(RefreshTokenViewModel model) { if (this.ModelState.IsValid) { try { // Create the client with which we will be connecting to the server. var webServerClient = new WebServerClient(this.AuthorizationServerDescription, clientIdentifier: model.ClientId, clientSecret: model.ClientSecret); // Create an AuthorizationState instance with only the refresh token set. This is all that is needed for // OAuth to be able to determine what token is to be refreshed var authorizationState = new AuthorizationState { RefreshToken = model.RefreshToken }; // Refresh an access token (http://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-6) // This method will use the client identifier and client secret used when constructing the WebServerAgentClient instance webServerClient.RefreshAuthorization(authorizationState); this.ViewBag.AccessToken = authorizationState; } catch (Exception ex) { this.ViewBag.Exception = ex; } } return this.View(model); }
public ViewResult RefreshToken() { // We will set-up correct default values to make it easier for the user to start testing var model = new RefreshTokenViewModel { ClientId = "demo-client-1", ClientSecret = "demo-client-secret-1", }; return this.View(model); }