thinktecture identityserver - 错误客户端应用程序未知或未经授权

时间:2016-04-04 19:10:58

标签: asp.net-mvc oauth oauth-2.0 openid-connect identityserver3

您好我在使用Thinktecture IdentityServer时遇到错误 错误消息 客户端应用程序未知或未经授权。 出现而不是登录。我可以直接登录身份服务器但是我收到消息"您没有获得任何应用程序的许可" 我想我的重定向网址可能有问题,但我似乎无法找到该错误。此外,我的MVC客户端应用程序工作正常,直到我尝试添加身份服务器

非常感谢任何帮助。

谢谢迈克尔

这是我的Constants.cs文件

public class Constants
{
    public const string API = "http://localhost:57020/";
    public const string Client = "https://localhost:44306/";
    public const string Mobile = "";

    public const string IdServerUri = "https://identityserver/embedded";

    public const string IdServer = "https://localhost:44302/identity";
    public const string IdServerToken = IdServer + "/connect/token";
    public const string IdServerAuthorize = IdServer + "/connect/authorize";
    public const string IdServerUserInfo = IdServer + "/connect/userinfo";
}

这是我的WebClient中的Startup.cs

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseCookieAuthentication(new CookieAuthenticationOptions()
        {
            AuthenticationType = "Cookies"
        });

        app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
        {
            ClientId = "WebClient",
            Authority = Constants.IdServer,
            RedirectUri = Constants.Client,
            SignInAsAuthenticationType = "Cookies",

            ResponseType = "code id_token",
            Scope = "openid profile",

            Notifications = new OpenIdConnectAuthenticationNotifications()
            {
                MessageReceived = async n =>
                {
                    EndpointAndTokenHelper.DecodeAndWrite(n.ProtocolMessage.IdToken);
                    EndpointAndTokenHelper.DecodeAndWrite(n.ProtocolMessage.AccessToken);

                    var userInfo = await EndpointAndTokenHelper.CallUserInfoEndpoint(n.ProtocolMessage.AccessToken);
                }
            }

        });
    }
}

以下是我的Identity Server的Startup.cs

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.Map("/identity", idServer =>
        {
            idServer.UseIdentityServer(new IdentityServerOptions
            {
                SiteName = "Embedded Identity Server",
                IssuerUri = Constants.IdServerUri,
                SigningCertificate = LoadCertificate(),

                Factory = new IdentityServerServiceFactory()
                    .UseInMemoryUsers(Users.Get())
                    .UseInMemoryClients(Clients.Get())
                    .UseInMemoryScopes(Scopes.Get())
            });
        });
    }

    X509Certificate2 LoadCertificate()
    {
        return new X509Certificate2(
            string.Format(@"{0}\bin\myCertificate.com.pfx",
            AppDomain.CurrentDomain.BaseDirectory), "******");
    }
}

最后这是我的client.cs

public static IEnumerable<Client> Get()
    {
        return new[]
        {
            new Client
            {
                Enabled = true,
                ClientId = "WebClient",
                ClientName = "WebClient App",
                Flow = Flows.Hybrid,
                RequireConsent = true,

                RedirectUris = new List<string>
                {
                    Constants.Client
                },
            }
        };

0 个答案:

没有答案