Unable to get Box Authenticated Session
Hi,
I am integrating my application with Box using .Net SDK. I have upgraded the BOX.V2 to 3.18.0.
I am following the documentation in the start guide.
[Route("return")] public async Task<IActionResult> Return(){ var code = Request.Query["code"]; this.BoxAuthenicatedSession = await this._boxClient.Auth.AuthenticateAsync(code); var client = new BoxClient(this._boxConfig, this.BoxAuthenicatedSession); // PERFORM API ACTIONS WITH CLIENT }
this is the code that is written over there..
I am able to fetch the code. while getting authenticatedsession, my code is returning an exception that object reference is not set to an instance of object.
Please help me to solve this issue.
-
Hi ,
It might help to see a full sample app with these features implemented. I have this sample set up with the start (redirect user) and return (code exchange) segments of the OAuth 2 process. That might help provide some context to the overall build.
Let me know if you have any questions about that,
Jon
-
Hi there ,
I really appreciate your quick response. I have managed to get authentication using the provided code and upload a file to my box account. now I wanted to create a shared link for the file.
var fileId = newFile.Id; var unshareAt = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 12, 0, 0); BoxSharedLinkRequest sharedLink = new BoxSharedLinkRequest() { Access = BoxSharedLinkAccessType.open, UnsharedAt = unshareAt, Permissions = new BoxPermissionsRequest { Download = true } }; // Create shared link BoxFile file = await _boxClient.FilesManager.CreateSharedLinkAsync(fileId, sharedLink);
I am getting exception on CreateSharedLinkAsync that
The API returned an error [BadRequest | raadfgg5sjey4lm0.01cnp3vkglp90cg7sijsis1t16d] bad_request - Bad Request
Can you please guide me here ? I am understanding that for creating shared link boxclient is not required but adminclient is required. and for adminclient I need to auth my app using JWT authentication. Can I have the authority to perform both operations using boxclient? please guide me here.
your support in this regard will be highly appreciated.
Please sign in to leave a comment.
Comments
2 comments