Error: Grant credentials are invalid
I created a custom app with auth type = "OAuth 2.0 with Client Credentials Grant (Server Authentication)" and access type = "App access only" but I keep getting the error Grant credentials are invalid. I copy the creds right from the screen so I don't see how they can be invalid. My Client ID is "6hvihoiygmj1r00bs8gclv8f4jwhiqem". Any help would be appreciated.
-
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
-
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);
投稿コメントは受け付けていません。
コメント
2件のコメント