Upload to personal account
AnsweredHi everyone,
I have a problem that when I'm uploading a file, with the app authorized, it is creating a new account to upload the files and I can only access these files in the master panel in content.
I'm testing on multiple accounts and it's always the same result as the app will cover multiple customers.
How can I go up to my personal account?
-
Official comment
Hey!
Can you send me a code example of what you are doing to upload content?
Thanks,
Alex, Box Developer Advocate
Comment actions -
Hey Alex,
I'm using the oficial .NET sdk.
My app is authenticated and is App Access Level and is using OAuth 2.0 Credentials with public key.
Documentation: https://github.com/box/box-windows-sdk-v2
using (FileStream stream = new FileStream(name, FileMode.Open))
{
BoxFileRequest req = new BoxFileRequest()
{
Name = name,
Parent = new BoxRequestEntity() { Id = folderId }
};
newFile = await _boxCliente.FilesManager.UploadAsync(req, stream);
}When I upload a file it will be saved in another account on content in the admin console. The integration is creating a new account between my account and the app integration.
-
Great! For the client you instantiated, what parameters did you pass in? In that github repo you sent, there are several authentication type options. This probably explains why it is going to the application service account's content repository and not your own personal one. The client would need to be created with your users information.
Hope this helps!
-
I'm using this method to autheticate.
var boxJWT = new BoxJWTAuth(
new BoxConfig(
_boxAppSettings.ClientID, _boxAppSettings.ClientSecret, enterpriseId,
_boxAppSettings.AppAuth.PrivateKey, _boxAppSettings.AppAuth.Passphrase, _boxAppSettings.AppAuth.PublicKeyID
)
);
var adminToken = boxJWT.AdminToken();
_boxCliente = boxJWT.AdminClient(adminToken); -
Correct! The client you are making in the above code is using your JWT config information - this defaults to the service account (the account you are seeing content in). In order to place it in another user's account, you need to be making as-user calls. To do this with the .net sdk, you have to make a client using the credentials of the user you wish to make the API call as. Refer to this page. I believe there is sample code on the .net sdk github main page too.
Please sign in to leave a comment.
Comments
6 comments