OAuth Authentication Request Not Returning Code for .NET SDK
I'm trying to use the .NET SDK in my console application to upload a file to the box that is dynamically generated each day. I'm confused on the OAuth process. I've set up my OAuth2 application, and got the id, secret, and redirect_uri
var config = new BoxConfigBuilder(clientId, clientSecret, new Uri(redirect_uri)).Build();
var client = new BoxClient(config);
I try to make a web request to get the authorization code:
var rq = (HttpWebRequest)WebRequest.Create(config.AuthCodeUri);
HttpWebResponse rs = rq.GetResponse() as HttpWebResponse;
but it doesn't return a code in the body. Instead, it returns the HTML of the Grant Access page (as detailed in https://developer.box.com/guides/authentication/oauth2/with-sdk/). But this is a console app, there is no user to click "Grant Access" - I need to just get the actual auth code that I use within my code, without requiring and manual user steps. How do I get this code?
-
Hello,
A console app and Oauth 2.0 don't play well together since a user needs to grant access in the pop up. I would recommend using the JWT or CC app type. Here is an example JWT app in our .NET SDK.
Thanks,
Alex, Box Developer Advocate
Post is closed for comments.
Comments
1 comment