Welcome to the new Box Support website. Check out all the details here on what’s changed.

Issue in Generating authentication code which will be used to get access/refresh token.

New post

Comments

1 comment

  • JohannesMaria

    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

     

    0
    Comment actions Permalink

Please sign in to leave a comment.