Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
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


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.

  • User Avatar
    0
    tugrulkarakaya created

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

  • User Avatar
    0
    muhittincelik created

    We have default tenant.

    Our version is 5.6.2.

  • User Avatar
    0
    muhittincelik created

    Is this a bug ?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @muhittincelik,

    Have you disabled Multi Tenancy in your project ?

  • 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)

  • 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") }
    		}
    	};
    }
    
  • User Avatar
    0
    muhittincelik created

    Nothing changed. :(

  • 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() }
    		}
    	};
    }
    
  • 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.

  • User Avatar
    0
    muhittincelik created

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

  • User Avatar
    0
    ukocabicak created

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

  • User Avatar
    0
    muhittincelik created

    There is no package with that name on Nuget .

  • User Avatar
    0
    muhittincelik created

    I will try;

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

  • User Avatar
    0
    muhittincelik created

    :( same error.

  • 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.

  • 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.

  • User Avatar
    0
    muhittincelik created

    Which version is stable for AspNetZero Core & JQuery?

  • User Avatar
    0
    muhittincelik created

    Can you send me a running example.

    Thanks

  • User Avatar
    0
    ismcagdas created
    Support Team

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

  • 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

  • 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

  • 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

  • User Avatar
    0
    muhittincelik created

    Thanks İsmail.

    It is OK.

    Muhittin