Issue in Generating authentication code which will be used to get access/refresh token.
Hi Guys,
I'm new to box net. I'm using box net SDK with C# to integrate into my application.
For reference, i'm following this - https://github.com/jhoerr/box-csharp-sdk-v2
After creating a new app on the box I could get the client ID and client Secret key but I'm unable to generate access/refresh token which is to be done.
Sample Code
In the above attached code, var intialTokenPair = tokenProvider.GetAccessToken("Code"); I'm not sure how to get the code.
If I execute the code, it gives me unathorised_client error showing some grant type error.
How should I proceed further? I'm using C# language to implement this.
Any help will be greatly appreciated.
Thanks,
Harsh Makadia
-
Hi HarshMakadia,
the first thing I read in the readme of your link is:
Hey! Don't Use This!
It is sometime advisable to read it, that is why it is called Readme.
Following the above advise is to use the box windows sdk which you find here where the OAuth2 process is explained:
https://github.com/box/box-windows-sdk-v2#using-with-oauth2
The way this works is the following:
You provide your client id and client secret (be aware with OAuth2 the secret is not handled as secret the name is misleading) and a redirect uri. The uri must be an https uri
and the same as in the developer console.
First init your client:
var config = new BoxConfig(<Client_Id>, , ); var client = new BoxClient(config);
Then get an authcode. You will be redirected to the box login page where you login in and authorise your app.
After login the site redirects to your uri with the authcode appended as parameter. The sdk extracts it for you.
string authCode = await OAuth2Sample.GetAuthCode(config.AuthCodeUri, new Uri(config.RedirectUri)); await client.Auth.AuthenticateAsync(authCode);
Your refresh and access tokens are retrieved automatically by the client.
If you want to do this manually send the authcode along with your client id and secret to the box token endpoint as explained in this video:
https://www.youtube.com/watch?v=ha26tN8amI0
Let me know if it helps.
Thanks
Johannes
サインインしてコメントを残してください。
コメント
1件のコメント