.NET SDK code hangs at AdminToken()

New post



  • adblondin

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

    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

    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.

    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: 



    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. 


    John Townsend


    Comment actions Permalink

Please sign in to leave a comment.