Welcome to the new Box Support website. Check out all the details here on what’s changed.

Error: Grant credentials are invalid

New post

Comments

2 comments

  • Alex Novotny

    This is probably happening due to what you are sending in with the authorization call. Check here for more information. With App Access Only, the subject type should be user not enterprise. 

    Alex, Box Developer Advocate

     

    0
    Comment actions Permalink
  • Greg Bursett

    Thank you for the reply. The document you shared is the one I am using. I am getting the UserID from the General Settings tab and the OAuth 2.0 Credentials from the Configuration tab. Here is what I am attempting using .net box sdk:

    var boxConfig = new BoxConfigBuilder("6hvihoiygmj1r00bs8gclv8f4jwhiqem", "<secret>").Build();
                var boxCCG = new BoxCCGAuth(boxConfig);
                Task<string> response = boxCCG.UserTokenAsync("17293138289"); //valid for 60 minutes so should be cached and re-used
                while (!response.IsCompleted)
                {
                    //still waiting;
                }
                objBoxClient = boxCCG.UserClient(response.Result.ToString(), "17293138289");
                objBoxClient.Auth.SessionAuthenticated += delegate (object o, SessionAuthenticatedEventArgs e)

    I have also tried using Rest Sharp like this:

    RestRequest objRestRequest = new RestRequest("oauth2/token", Method.Post);
                objRestRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
                objRestRequest.AddHeader("client_id", "6hvihoiygmj1r00bs8gclv8f4jwhiqem");
                objRestRequest.AddHeader("client_secret", "<Secret>");
                objRestRequest.AddParameter("grant_type", "client_credentials");
                objRestRequest.AddHeader("box_subject_type", "user");
                objRestRequest.AddHeader("box_subject_id", "17293138289");

                RestClient client = new RestClient("https://api.box.com");
                Task<RestResponse> response = client.ExecuteAsync(objRestRequest);

    0
    Comment actions Permalink

Post is closed for comments.