Upload file to box vial Desktop application
Hi,
I am developing a desktop application and need to upload files generated by my application to a box account.I am having difficulty in generating the authorization code through my C# code to get the access toke. Do i need to explicitly login to the box account first or is there any way to login to the box account via box API? Furthermore, how to generating the code after that.
My code for generating the auth_code is below but it the error following error in response : "There seems to be some problem with this application" and "invalid client".
C# Code
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
string param = string.Format("?response_type=code&client_id={0}&redirect_uri={1}&state=authenticated", CLIENT_ID, "http://localhost");
var client = new RestClient("https://account.box.com/api/oauth2/authorize");
var request = new RestRequest(Method.GET);
request.AddHeader("content-type", "application/x-www-form-urlencoded");
request.AddParameter("application/x-www-form-urlencoded", param, ParameterType.GetOrPost);
var response = client.Execute(request);
var json = JObject.Parse(response.Content);
return Convert.ToString(json["code"]);
-
Hi
Thanks for coming to the Box Community with your question! Unfortunately, you won't be able to get your authorization code programmatically; this code requires you to press a button to grant access to the app and get back the authorization code. However, you can use JSON Web Tokens with your application in order to get around this: https://developer.box.com/docs/authentication-types-and-security#section-oauth-2-with-jwt
Let us know if you have further questions about this, and have a great day!
Please sign in to leave a comment.
Comments
1 comment