Skip to main content
Question

UploadAsync

  • May 22, 2025
  • 9 replies
  • 25 views

Forum|alt.badge.img

tried to upload file using uploadasync we are getting an error grant_type is unatuthorzed to this client_id. may i know what we are missing.

 

var config = new BoxConfigBuilder("mm9idicrsyd6qmsdfdsfsdsdfwemk2", "dsfdsfsdfrewewrwe").Build();
            var session = new OAuthSession("kljkjsdfdsfsdfsdfsdfsfs", "NOT_NEEDED", 3600, "bearer");
            var client = new BoxClient(config, session);
            //var x = client.FoldersManager.GetFolderItemsAsync("0", 500).Result;
            using (FileStream stream = new FileStream(@"d:\pdfchkfile2.pdf", FileMode.Open))
            {
                BoxFileRequest req = new BoxFileRequest()
                {
                    Name = "example.pdf",
                    Parent = new BoxRequestEntity() { Id = "0" }
                };
                var newFile = client.FilesManager.UploadAsync(req, stream).Result;
            }

9 replies

Forum|alt.badge.img

Hi,
the code seems to be ok - I managed to upload a file using your code snippet. I think the problem is somewhere in you app settings or permissions. What application type are you using? May I ask you about the app id - I'll check your settings.

Regards,
Łukasz Socha


Forum|alt.badge.img

Hi,
I am using .net framework 5 windows application. App name is dsr and enterprise I'd is 883637019.


Forum|alt.badge.img

And what authentication type app do you use? JWT, CCG or OAuth. App id may be found as last part of url when you enter your app from dev console.


Forum|alt.badge.img

I am generating token through dev console and i am using that in SDK. I can use jwt or oauth if you suggest


Forum|alt.badge.img

During creating the app you had to choose one of the authentication method. Did you remember which one did you choose?


Forum|alt.badge.img

I think jwt.


Forum|alt.badge.img

I noticed that this error 'The grant type is unauthorized for this client_id' appears when you change some settings in Dev Console, save changes, but still use the old access token. Each settings change requires generating and using new developer token. Let me know if this was this your case - generate new developer token, try to use it and let me know if it helped.


Forum|alt.badge.img

I tried as you said , it worked

thank you


Forum|alt.badge.img

May i know where from i get 

<Private_Key>, <JWT_Private_Key_Password>, <JWT_Publickey>

is this only for paid users? then how can i get token without this. I want token to be generated on the fly.