How to specify Box customer for AdminCient
AnsweredI have currently have 2 Box Enterprise accounts that I would like to be able to access with JWT auth from a single App.
For example, I have Enterprise ID 1234 and Enteprise ID 5678. The app was created under 1234, and was given access to 5678 through the admin portal. When using the UserClient, I am able to retrieve files for users in either enterprise account. However, using the AdminClient, I am not able to specify the enterprise to use, and it defaults to 1234.
I assume I need to do this when I create the token, but don't see where, and I was unable to find this in the documentation. I am creating the AdminClient like so:
private BoxClient CreateNewAdminClient()
{
var client = GetJWTAuth().AdminClient(GetToken());
return client;
}
private string GetToken()
{
var token = GetJWTAuth().AdminToken();
return token;
}
private BoxJWTAuth GetJWTAuth()
{
IBoxConfig config = ConfigureBoxApi();
return new BoxJWTAuth(config);
}
private static IBoxConfig ConfigureBoxApi()
{
IBoxConfig config = null;
using (FileStream fs = new FileStream(@"config.json", FileMode.Open))
{
config = BoxConfig.CreateFromJsonFile(fs);
}
return config;
}
-
Hi ,
I was just digging through the Windows SDK to see if there was a way of setting this directly when creating the admin client. In some of the SDKs (e.g. Node) an enterprise ID can be specified as a parameter when creating the client - I didn't see that directly in the Windows SDK.
Here's what I would suggest - if you auth the admin client using the config.json file that was downloaded when creating the app you can maintain two versions - one with one of the enterprise IDs, the second with the other. That should allow you to generate admin clients for both depending on your needs.
- Jon
Please sign in to leave a comment.
Comments
1 comment