使用auth0.net调用Authentication API时获取404

时间:2016-10-05 07:06:26

标签: c# authentication auth0

我正在尝试使用auth0.net(Auth0 API的.NET客户端)进行身份验证,但是,我收到Auth0.Core.Exceptions.ApiException错误,其HTTP状态代码为NotFound (404)。< / p>

我正在使用以下代码:

var client = new AuthenticationApiClient(new Uri(Auth0Url));

var authenticationRequest = new AuthenticationRequest();
authenticationRequest.ClientId = ClientId;
authenticationRequest.Username = username;
authenticationRequest.Password = password;
authenticationRequest.Connection = "Username-Password-Authentication";

AuthenticationResponse response = null;
Task.Run(async () =>
{
    response = await client.AuthenticateAsync(authenticationRequest);
}).Wait();

这里有什么问题? Management API工作正常,ClientID是正确的。

1 个答案:

答案 0 :(得分:1)

我自己就是这个问题。

两件事。

首先确保您使用的是正确的API网址。

E.g。

sub foo (*@_ where .so) { ... };

而不是 https://<company>.au.auth0.com/api/v2

第二确保您使用的是基本API

E.g。

https://<company>.au.auth0.com

而不是 https://<company>.au.auth0.com/api/v2