Base solution for your next web application
Open Closed

Invalid_grant error from Api Client #5611


User avatar
0
muhittincelik created

Hi

Our web mvc project running and we can login.

But we can not authenticate from api client, we got invalid_grant , invalid_user_or_password error.

But username and password are correct, client id correct, address correct.

Do you have any idea ?

Muhittin

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

24 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @muhittincelik,

    What is your ABP and AspNet Zero version ? I remember a similar problem in one of the v5.x versions.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    tugrulkarakaya created

    do you have tenantId. if yes do not forget setting proper cookie Abp.TenantId = YourTenantId

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    We have default tenant.

    Our version is 5.6.2.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    Is this a bug ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @muhittincelik,

    Have you disabled Multi Tenancy in your project ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    MultiTenancyEnabled = true

    And i have 2 warning in dependencies; I rebuild several times.

    1- *.Core.Shared - System.ComponentModel.DataAnnotations (!) 2- *.Web.Mvc - npm.bootstrap4-datetimepicker.moment-timezone (not installed)

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    I think I have found the problem;

    Assuming you have below settings in appsettings.json file;

    "ApiName": "default-api",
    "ApiSecret": "secret"
    

    You need to change GetApiResources method of IdentityServerConfig like below;

    public static IEnumerable<ApiResource> GetApiResources()
    {
    	return new List<ApiResource>
    	{
    		new ApiResource("default-api", "Default (all) API")
    		{
    			Description = "AllFunctionalityYouHaveInTheApplication",
    			ApiSecrets= {new Secret("secret") }
    		}
    	};
    }
    
    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    Nothing changed. :(

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ukocabicak created

    You are probably passing wrong secret to server. Although secret must be hashed.

    Try hashing the secret.

    public static IEnumerable<ApiResource> GetApiResources()
    {
    	return new List<ApiResource>
    	{
    		new ApiResource("default-api", "Default (all) API")
    		{
    			Description = "AllFunctionalityYouHaveInTheApplication",
    			ApiSecrets= {new Secret("secret").Sha256() }
    		}
    	};
    }
    
    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @muhittincelik is it possible to share your project via email to [email protected] ? If so, we can try to help you in a short time.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    Sha256() için böyle bir extension yok dedi. Siz deneyebildiniz mi ?. Webex açabilirim bir bakabilirsiniz.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ukocabicak created

    It's under  IdentityServer4.Models namespace that you are probably missing. You can get it from nuget.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    There is no package with that name on Nuget .

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    I will try;

    ApiSecrets= {new Secret("secret".Sha256())}

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    :( same error.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ukocabicak created

    @muhittincelik can you share server logs?

    Its very hard to troubleshoot identityserver problems without logs.

    You can implement how to via how to log identityserver if you haven't already.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    I think, i need webex or teamviwer. I can not configure Loging.

    When i install nuget package there is exclamation on it.

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    Which version is stable for AspNetZero Core & JQuery?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    Can you send me a running example.

    Thanks

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @muhittincelik is it possible to share your project via email to [email protected] ?

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    You can use your 5.6.2 Core & JQuery package. I didnt add anything yet.

    I am learning your framework and i will integrate our desktop software with your web application via api.

    Muhittin

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    I got the following output now; I think i have no authorization for getuserlist. But I have all auths.

    token deteils... ... ..

    Unauthorized

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @muhittincelik yes, raw v5.6.2 project has a problem like you said but according to my tests, it is fixed via https://github.com/aspnetzero/aspnet-zero-core/commit/159085163e4fb12dd77c964d5b706969662fac7c

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)
  • User Avatar
    0
    muhittincelik created

    Thanks İsmail.

    It is OK.

    Muhittin

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)