Getting the POST variables in OAuth2Provider.AuthenticateAsync


I have an update issue when updating from ServiceStack 8.0.0 to 8.3.0.
I have created an own OAuthProvider, inheriting from OAuth2Provider. In the function AuthenticateAsync there is the Authenticate request object. This one used to have the properties oauth_token, qop and State. I misused them in my application. These properties are removed in version 8.3.0.

But my frontend is sending these as a post variable. I would expect to be able to retrieve them with e.g.:
var qop = authService.Request.FormData[“qop”];
but here the NameValueCollection FormData is empty.

Is there a way to get the POST variables in the call /auth/MyOAuth in the overridden function AuthenticateAsync of OAuth2Provider?


That is the way to access the Request FormData but not sure why it would be empty, are you sure you’re posting a application/x-www-form-urlencoded Content-Type? Is Request.QueryString empty as well?

My Content-Type is application/json. Does that matter?
The Request,QueryString is also empty in the debugger. Things like the RawUrl are filled in.

JSON isn’t FormData, which needs to send either a application/x-www-form-urlencoded or multipart/form-data Content-Type, i.e. the same request a HTML Form would post.

If you want to keep a JSON Request Body I’d recommend adding the missing property to the queryString.

Ah, ok. I must have hit this problem before. Thanks for pointing me out.
I’ll add a new custom route for this endpoint, convert the request and send it on with ResolveService. I didn’t realize that option before. So thanks for answering my stupid questions :slight_smile:

1 Like