November Happy Hour will be moved to Thursday December 5th.

EPiServer.ServiceApi - {"error":"invalid_grant"}

Vote:
 

I've followed instructions for setting up ServiceAPI:

http://world.episerver.com/documentation/Items/Episerver-Service-API/Configuration-and-overview/Setting-up-EPiServerServiceApi/

using (var client = new HttpClient())
{
  client.BaseAddress = new Uri("https://cmsservice.polarisdev.com");
  var fields = new Dictionary
  {
    { "grant_type", "password" },
    { "username", "admin" },
    { "password", "store" }
  };

var response = client.PostAsync("/episerverapi/token", new FormUrlEncodedContent(fields)).Result;

...

}

when running and hit the client.PostAsync(), the response is {"error":"invalid_grant"}

The IIS endpoint is localhost, self signed cert is in trusted store, host file is good, connection string is good (mapped to commerce database), confirmed the two EPiServerServiceApi recs are in the tblUserPermission in the CMS database.  

If anyone has seen this before and corrected the issue, please respond with fix.

#144795
Feb 18, 2016 21:07
Vote:
 

Hi,

Have you found a fix for the issue ? I am having the same.

Thanks,

David

#188672
Feb 28, 2018 21:53
Vote:
 

Hi,

Any solution for the error-{"error":"invalid_grant"}, when accesing token through postmann? Thanks

#195556
Jul 30, 2018 14:12
Vote:
 
#195560
Edited, Jul 30, 2018 15:16
Vote:
 

Once you login in CMS

Grant permission for the Config user to use ServiceApi.

  1. Go to the admin view > Config >Security > Permissions for Functions.
  2. Add the user or group to the EPiServerServiceApi Read Accessright. This user is for authenticating when you consume the ServiceApi
  3. Similarly WriteAccess

It did worked for me

#201868
Mar 05, 2019 18:35
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.