Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Receiving incorrect access token from authentication server (Auth0)

$
0
0

I have an ASP .Net Core 1.1 MVC Web App which accesses a web API (also written in ASP .NET 1.1 MVC).

The Auth0 authenticaion I believe is working fine on the API side. But I am struggling on the web app side.

I have the following code:

var tokenResponse = await client.PostAsync("https://codexcreations.eu.auth0.com/oauth/token",
                    new FormUrlEncodedContent(new List<KeyValuePair<string, string>>
                    {
                new KeyValuePair<string, string>("grant_type", "client_credentials"),
                new KeyValuePair<string, string>("scope", "InspectionsAPI"),
                new KeyValuePair<string, string>("client_id", _auth0Settings.ClientId),
                new KeyValuePair<string, string>("client_secret", _auth0Settings.ClientSecret),
                    }));
var tokenResponseAsString = await tokenResponse.Content.ReadAsStringAsync();
                var token = JObject.Parse(tokenResponseAsString)["access_token"].Value<string>();

That seems to work, except that the token I receive is weird:

0vxmfCJUc5K2bl4XfF2QoP6-3tnzdaBUZAVpIizNCAF_CEWxgmn0sFLz_FC_AUZ9

That doesn't look correct, and doesn't function either. I tried it using IdentityModel too:

            TokenClient tokenClient = new TokenClient("https://codexcreations.eu.auth0.com/oauth/token", _auth0Settings.ClientId,

_auth0Settings.ClientSecret); TokenResponse tokenResponse = await tokenClient.RequestClientCredentialsAsync("read:inpsections");

But I get the same token. Any ideas where I'm going wrong? I'm unfortunately very new to authentication - and in fact to ASP Net and web development in general! Thanks


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>