Error IdentityServer "invalid_client" always returned

I am trying to use IdentityServer3, but I donโ€™t know why I get the error "invalid_client" always, always no matter what I do.

This is the code I'm using:

//Startup.cs (Auth c# project)
public void Configuration(IAppBuilder app) {
    var inMemoryManager = new InMemoryManager();
    var factory = new IdentityServerServiceFactory()
        .UseInMemoryClients(inMemoryManager.GetClients())
        .UseInMemoryScopes(inMemoryManager.GetScopes())
        .UseInMemoryUsers(inMemoryManager.GetUsers());

    var options = new IdentityServerOptions {
        Factory = factory,
        RequireSsl = false
    };

    app.UseIdentityServer(options);
}

InMemoryManager assistant.

//InMemoryManager.cs
public class InMemoryManager {
    public List<InMemoryUser> GetUsers() {
        return new List<InMemoryUser> {
            new InMemoryUser {
                Username = "alice",
                Password = "password",
                Subject = "2",
                Claims = new [] {
                    new Claim("User name", "Alice")
                }
            }
        };
    }

    public IEnumerable<Scope> GetScopes() {
        return new[] {
            new Scope {
                Name = "api1",
                DisplayName = "API 1"
            }
        };
    }

    public IEnumerable<Client> GetClients() {
        return new[] {
            new Client {
                ClientName = "Silicon on behalf of Carbon Client",
                ClientId = "carbon",
                Enabled = true,
                //AccessTokenType = AccessTokenType.Reference,

                Flow = Flows.ResourceOwner,

                ClientSecrets = new List<Secret> {
                    new Secret("secret".Sha256())
                },

                AllowedScopes = new List<string> {
                    "api1"
                }
            }
        };
    }
}

This is the result that I always get.

Postman error

I use a postman to try Auth Server, but I always get this error. I read other solutions, but nobody seems to work, I don't know what else to try.

Greetings.

+12
source share
3 answers

Your request will be as follows:

  • clientId/clientSecret. carbon/secret . 1
  • . username/password shoud be alice/password . , offline_access . 2
+1

client_secret: secret . !

enter image description here

+1

, IdentityServer 4 . ( ) . .

, IdentityServer, config.cs GetClients , AllowedGrantTypes GrantTypes.ResourceOwnerPassword ClientId client ro.client ( , Client. CS).

0
source

Source: https://habr.com/ru/post/1663281/