Try our conversational search powered by Generative AI!

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


I've followed instructions for setting up ServiceAPI:

using (var client = new HttpClient())
  client.BaseAddress = new Uri("");
  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.

Feb 18, 2016 21:07


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



Feb 28, 2018 21:53


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

Jul 30, 2018 14:12
Edited, Jul 30, 2018 15:16

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

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.