I am tring to implemented an OAuth2Authorization Server and I am tring to connect to it by DotNetOpenAuth.AspNet.Clients.OAuth2Client in a MVC 4 webclient project.
In my SPA webclient I am able to obtain an AccessToken overriding QueryAccessToken of OAuth2Client.
With my AccessToken I am able to call a REST API service and obtain successful result as user extra data.
....
HttpWebRequest apiRequest =
(HttpWebRequest)WebRequest.Create(".....://localhost:4314/api/TodoList");
DotNetOpenAuth.OAuth2.ClientBase.AuthorizeRequest(apiRequest, AccessToken);
....
But, after some time my AccessToken goes to expire and I receive an error, so I need to refresh my AccessToken for next REST service calls.
How can I refresh my AccessToken inside a method of OAuth2Client?
Is it possible to use ClientBase.RefreshAuthorization(....)?
Thanks
Carmelo
Using the
DotNetOpenAuth.AspNetnamespace for authorization (using the access token repeatedly for web requests) is swimming upstream. That namespace has clients that are only intended for login (authentication).A better fit for what you’re doing would be to use the
WebServerClientclass, which is part of the core DotNetOpenAuth library. It automatically refreshes the access token as needed.