We have a stateful web application that maintains long living server session for each user (as long as user works with system session is alive) that need to work with Azure DevOps. We are using .NET client libraries.
We are keeping VssConnection for the session lifetime. We are creating connection like this:
var vssOAuthAccessTokenCredential = new VisualStudio.Services.OAuth.VssOAuthAccessTokenCredential(accessToken);
var connection = new VssConnection(connectionUrl, vssOAuthAccessTokenCredential);
The problem here is that access token expires after some time and I don’t see any kind of connection/credential class in SDK that will accept some callback that I can pass to refresh token.
I tried to implement my own IVssCredentialPrompt, but when I’m creating new VssConnection passing my IVssCredentialPrompt implementation and CredentialPromptType.PromptIfNeeded I’m getting
System.ArgumentException: The prompt option is invalid because the process is not interactive. Parameter name: PromptType.
I also can’t create my own implementation of FederatedCredential since it requires IssuedToken instance which constructor is internal.
What is recommended solution for this case?