MADCookie
MADCookie

Reputation: 2662

How to use latest AuthDtos when services are running older ServiceStack versions?

As a client, in our organization, we use Client Credential flows for API to API calls. I'm running ServiceStack v.8.2.2. This version of AuthDtos uses AccessToken property, but the servers I call are using ServiceStack v6 and their authenticate route expects oauth_token.

It seems to me, I can no longer use ServiceStack.Authenticate from the v8.2.2 library. Instead, I have to build a POST request to my server manually calling their "/authenticate" route with a request model of oauth_token = {my Identity Server client token} and provider = "BearerTokenAuthProvider"

How is a newer client supposed to authenticate to older ServiceStack servers?

This question is a variation of "How to work around a breaking change in ServiceStack.AuthDtos removing oauth_token"

Upvotes: 0

Views: 30

Answers (1)

mythz
mythz

Reputation: 143369

You don't need to use the built-in DTOs, you can use a local modified copy with the properties you want, e.g:

public class Authenticate : IPost, IReturn<ServiceStack.AuthenticateResponse>
{
    public Authenticate() {}
    public Authenticate(string provider) => this.provider = provider;

    public string provider { get; set; }
    public string UserName { get; set; }
    public string Password { get; set; }
    public bool? RememberMe { get; set; }

    public string AccessToken { get; set; }
    public string AccessTokenSecret { get; set; }
    public string ReturnUrl { get; set; }

    public string ErrorView { get; set; }
    public Dictionary<string, string> Meta { get; set; }

    public string oauth_token { get; set; }
}

Upvotes: 0

Related Questions