Skip to main content
Question

invalid_grant when using Java SDK

  • May 22, 2025
  • 3 replies
  • 21 views

Forum|alt.badge.img

Hi all - I'm working on my initial box integration using a service account setup for App+Enterprise access. I'm receiving an invalid_grant - Grant credentials are invalid in response to this block of code. My clientId is 9fxqtste70ak8rcrf726p90aepxira09.

BoxCCGAPIConnection boxApi = BoxCCGAPIConnection.applicationServiceAccountConnection(
clientId, secret, enterpriseId
);
BoxFolder folder = BoxFolder.getRootFolder(boxApi);
for (BoxItem.Info itemInfo : folder) {
if (itemInfo instanceof BoxFile.Info) {
BoxFile.Info fileInfo = (BoxFile.Info) itemInfo;
log.info("fileInfo = " + fileInfo.getName());
// Do something with the file.
} else if (itemInfo instanceof BoxFolder.Info) {
BoxFolder.Info folderInfo = (BoxFolder.Info) itemInfo;
log.info("folderInfo = " + folderInfo.getName());
// Do something with the folder.
}
}

3 replies

Forum|alt.badge.img

Hello, 

Did you happen to make any changes to the scopes/access level after authorizing? If so, you will need to reauthorize in the admin console. 

Alex


Forum|alt.badge.img

I haven't done so - it looks like it is properly authorized.

 

BOX1_WrGCuLoDh791VOa9C_Lmxg.png


Forum|alt.badge.img

I was able to resolve this. I was using the wrong value for enterprise ID -- I was using the service account email address rather than the multi-digit enterprise ID from the admin account page.