.NET SDK code hangs at AdminToken()

New post

Comments

5 comments

  • adblondin

    Was this problem ever resolved, or was it just ignored?

    0
    Comment actions Permalink
  • srudloff

    I am having this issue right now also!

     

    I would like to know how to resolve this issue, it is preventing me from completing my project

    0
    Comment actions Permalink
  • adblondin

    This is may be related to a known Box issue (https://github.com/box/box-windows-sdk-v2/issues/638).   I was able to determine the AdminToken() method was hanging when invoked on the main thread of a WebAPI Controller.  I was able to successful bypass the issue by spawning a new thread to execute the logic that ultimately invokes the AdminToken() method.

    0
    Comment actions Permalink
  • alfredbr

     is correct.

    You can get this to work if you create the AdminToken in a thread other than your controller thread. 

    This is what worked for me:

     

     

    BoxClient _boxClient = null;
    var thread = new System.Threading.Thread(() =>
    {
       var boxJWT = new BoxJWTAuth(boxConfig); // create boxConfig elsewhere
       var adminToken = boxJWT.AdminToken(); // create adminToken in new thread
       _boxClient = boxJWT.AdminClient(adminToken); // set your _boxClient
    });
    thread.Start(); // start the thread
    thread.Join(); // wait for the thread to finish (ugly code).
    Debug.Assert(_boxClient != null); // success!

     

     

    This is discussed in depth here: 

    https://github.com/box/box-windows-sdk-v2/issues/638

     

    0
    Comment actions Permalink
  • towns

    Hey Everyone, 

     

    We are aware of the issue with getting Admin Tokens using the .NET SDK. We have a PR that is working its way through the process. Once that PR lands successfully we will cut a new release of the SDK. Our ETA for this is early next week. 


    Thanks,

    John Townsend

     

    0
    Comment actions Permalink

Please sign in to leave a comment.