Service Account Can't Access Files
I'm struggling to follow what's needed to access files using the service account. I'm trying to access enterprise files from our custom app's (a.k.a. API) using the .NET SDK using the following code which result in 2 errors:
// Access Token and creating Client
var config = new BoxConfig(ClientID, ClientSecret,
EnterpriseID, PrivateKey, Passphrase, PublicKeyID); BoxJWTAuth boxAuth = new BoxJWTAuth(config); _adminToken = boxAuth.AdminToken(); client = boxAuth.AdminClient(_adminToken);
// Using client to get file info
BoxFile fileInfo = await client.FilesManager.GetInformationAsync(fileId);
return fileInfo;
Error 1: First few calls to Box to get a token I receive an error: "Object reference not set to an instance of an object. at Box.V2.JWTAuth.BoxJWTAuth.GetToken(String subType, String subId)". After a few retries and waiting around the code starts working again.
Error 2: On API call to get file info I received the following error: "The API returned an error [NotFound | gfi7tjgdeo5bezo9.010f07144180ddd36727a928fe468b598] not_found - Not Found".
As for Error 2, after reading through some of the comments I found out that the current user (AdminClient) was "AutomationUser_#@boxdevedition.com" with a name (Postman App). Why is this? Not sure which user to use to access folders and files.
-
Hi , Not sure about your Error #1 but for the last part, since you have created an Box application with Oauth with JWT authentication approach, an integration user is associated with each application. This integration users has the name of your application in your case Postman App with email address like "AutomationUser__@boxdevedition.com". Also your integration will only get access to files & folders while the access is made available to this integration user.
Please sign in to leave a comment.
Comments
1 comment