Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Getting 404 issue when requesting the token from postman/Restlet API #545

Closed
karthickramasamy08 opened this issue Jul 9, 2019 · 0 comments

Comments

@karthickramasamy08
Copy link

Hi Team,

I have created the new API project in .NET Core 2.2 version and need to configure OAuth 2 client credential grant type, in my case when a request from the server & processed the request & return the response to the same server. This is not an OAuth client configuration.

So, I have configured the AspNet.Security.OpenIdConnect.Server in my Startup.cs file. I didn't get the access token value from the Open Connect Id server Provider and returned 404 Not-found error from the Postman/Restlet API extension.

Please find the below Startup code.

`public void ConfigureServices(IServiceCollection services)

    {
        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

        services.AddAuthentication().AddOpenIdConnectServer(options =>
        {
            options.TokenEndpointPath = new PathString("/connect/token");
            options.AuthorizationEndpointPath = new PathString("/connect/authorize");

            options.Provider.OnValidateTokenRequest = context =>
            {   
                if (string.Equals(context.ClientId, this.Configuration["ClientCredentials:ClientId"], StringComparison.Ordinal) &&
                    string.Equals(context.ClientSecret, this.Configuration["ClientCredentials:ClientSecret"], StringComparison.Ordinal))
                {
                    context.Validate();
                }

                return Task.CompletedTask;
            };
        });
    }`

Then, added the below code in the same file.

public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseAuthentication(); }

I have used this URL (https://localhost:44397/token) for getting access token from the Restlet API chrome extension/Postman app. Please help to resolve this and explain the solution to my problem.

Otherwise, need to change anything in the startup code. Please suggest your ideas.

Regards,
Karthick R

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant