An MVC-based demonstration for Box's OAuth implementation in the v2 API. This is based on the Box C# SDK (API v2).
Creative Commons Attribution 3.0 Unported License
This project is available as a NuGet package.
You can run this project as-is or integrate it into an existing MVC application with the NuGet package.
Part of the OAuth2 workflow involves an HTTPS redirect from Box's site to the one you'll be running here. An HTTPS URL for your site must be pre-registered with Box in order for everything to work. (This pre-registration is done in order to prevent rogue redirects.) Visual Studio doesn't enable SSL by default, so there are a few manual steps required to make it all work.
- In the Solution Explorer, left-click on the MVC project to select it.
- Press F4 to bring up the project's Properties.
- Change 'SSL Enabled' from False to True. The SSL URL field should be automatically populated.
- Copy the SSL URL to the clipboard.
- Now right-click on the project name and select 'Properties'
- Click the 'Web' tab
- In the 'Servers' section find the text box labeled 'Project Url'
- Paste the SSL URL into this text box and save the changes.
- Browse to http://developers.box.com
- Click on "My Box Apps" on the upper right; log in.1
- Edit the application that you want to work with.
- Under 'OAuth2 Parameters' locate the 'redirect_uri' field.
- Paste the SSL URL into this field. Save your changes.
This configures your app to use SSL and tells Box to redirect you back to this HTTPS site after you've authenticated and agreed to let your application access your Box data.