Oauth 2.0 IdentityServer3,隐式流,如何获取令牌?

Oauth 2.0 IdentityServer3,隐式流,如何获取令牌?,oauth-2.0,identityserver3,Oauth 2.0,Identityserver3,我正在尝试使用IdentityServer3访问令牌URL。服务器的配置方式如下: var options = new IdentityServerOptions { LoggingOptions = new LoggingOptions { WebApiDiagnosticsIsVerbose = true, EnableWebApiDiagnostics =

我正在尝试使用IdentityServer3访问令牌URL。服务器的配置方式如下:

    var options = new IdentityServerOptions
        {
            LoggingOptions = new LoggingOptions
            {
                WebApiDiagnosticsIsVerbose = true,
                EnableWebApiDiagnostics = true,
                EnableHttpLogging = true,
                EnableKatanaLogging= true
            },
            Factory = new IdentityServerServiceFactory()
                .UseInMemoryClients(Clients.Get())
                .UseInMemoryScopes(Scopes.Get())
                .UseInMemoryUsers(Users.Get()),
            RequireSsl = false,
            EnableWelcomePage = false,

        };

        app.UseIdentityServer(options);
客户端配置:

 new Client
            {
                Enabled = true,
                ClientName = "JS Client",
                ClientId = "js",
                Flow = Flows.Implicit,
                RedirectUris = new List<string>
                {
                    "http://localhost:56522"
                },
                AllowedCorsOrigins = new List<string>
                {
                    "http://localhost:56522"
                },
                AllowAccessToAllScopes = true
            }
我收到无效客户端错误消息,日志显示: 操作返回“IdentityServer3.Core.Results.TokenErrorResult”,操作=ReflectedHttpActionDescriptor.ExecuteAsync


你知道我还错过了什么吗?

你的请求使用的是
密码
授权类型,这是OAuth资源所有者流,但是你的客户端被配置为使用OpenID Connect隐式流

更改客户端配置以使用资源所有者流,或者将请求更改为有效的OpenID连接请求

例如:
GET/connect/authorize?client\u id=js&scope=openid-api&response\u-type=id\u-token-token&redirect\u-uri=http://localhost:56522&state=abc&nonce=xyz
。这将带您进入登录页面


或者更好的是,使用像@Jenan建议的JavaScipt库,例如为您处理这些请求的。

您可以尝试隐式流为IdentityServer创建GET请求并获取令牌-尝试此请求:
/connect/authorize?client_id=js&redirect_uri=http://localhost:56522&response_type=token&scope=api&state=ef969376c1d34ccaa03f8cd449c96bd7
(保护的随机值-在客户端上进行比较)对于js客户端,可以使用此库-
Content-Type:application/x-www-form-urlencoded
grant_type:password
redirect_uri:http://localhost:56522
client_id:js
username:bob
password:secret
scope:api