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

Use Box API in Microsoft flow to generate a token then create a box user

New post

Comments

10 comments

  • cbetta

     im not too familiar with MS Flow. Is it possible to write scripts in Flow?

    0
    Comment actions Permalink
  • Losthere

    Thank you for your reply.

    Please give some time to provide some pics.

    0
    Comment actions Permalink
  • Losthere

     

    Here is what can be done with MS Flow.

    After creating an app in admin center, I get a client id and secret that I can use to get an access token through graph api.

    The upper hidden part in the pic is the tenant id (I'm assuming it's going to be Enterprise ID in box).

    After getting an access token with this API POST request, I could use it to perform tasks as create/delete .etc a user through another API call.

    I'm just hoping I can do this with box APIs too.

    We have many sub-admins that need to create/delete users in Office 365 without having to go through me.

    Microsoft Flow made it possible with Flow, and the sub-admin does not need to have any admin role to create or delete the user. This can be done by sharing the Flow with the sub-admin.

    In most cases, the new user with a new Office 365 account will need a box account and I'm hoping this can be done as in Office 365.

    Hope I have explained clearly, but please ask if needed.

    Thank you very much in advance.

    GetToken.JPG

    below is the "Show advance options" part

     

    GetToken1.JPG

     

    0
    Comment actions Permalink
  • cbetta

    Hi , I am not too sure our API probably won't work with that setup. We have 2 key ways of authenticating: client-side OAuth 2 and server-side JWT. JWT would require server-side encryption, which Flow doesn't' support (I think) and OAuth 2 would require a Box user to explicitly grant Flow to act on their behalf, and subsequently refresh the access token when needed. I don't think Flow is set up for either.

     

    Could you do me a favor and see if Flow supports OAuth 2 in any way?

    0
    Comment actions Permalink
  • Losthere

    Thank you for you help .

    Yes we can use OAuth 2 in flow.

    So in box, can I log in some Uri as an admin and get a user(admin) token, then use it to run tasks?

    Also, I was thinking if there is a way to create a user using API in powershell?

    Maybe from that I can get an idea on how to do it.

    Again, thanks a lot.

     

     

    0
    Comment actions Permalink
  • cbetta

     if you can use OAuth 2 then you can get an access token. With an access token any API call can be made. See developer.box.com for details.

     

    We offer a CLI that work on Windows and Mac:  https://github.com/box/boxcli

    0
    Comment actions Permalink
  • Andrew_Jameson

    Support,

     

    I am collaborating with a client and they have provided me with Viewer access to their project directory and I can manually go in and download the data which is all very easy.

     

    I am however an O365 user and would like to use Power Automate (flow) to automatically download the complete directory structure in their collaboration directory.  By the looks of things I need an API token, however I am thinking that this might give me access to whole of their Box.  Is it possible to have an API token that is specific to the folder that they can provide me to transfer the data.  I would not want the API token to give me full access to their Box.

     

    As I do not know much about Box it would be good to know what I want to achieve is possible and if it is then what do I need to ask my client to do to meet my requirements of transferring the data automatically.  Is there a step by step guide you can point me to please.

     

    Regards,

     

    Andrew

     

     

     

     

    0
    Comment actions Permalink
  • cbetta

    Hi  , so this is pretty straightforward. An application is generally authenticated as a user when making API call. In this case, this would mean that Power Automate (flow) accesses the Box API it's acting on your behalf, and therefore it will have all the same privileges you have as a user, including downloading the files and folders you have access to.

    0
    Comment actions Permalink
  • Andrew_Jameson

     

    Thanks even just using Power Automate, without any API I was able to see that this works, just a little nervous of seeing the whole of my clients data but now basically understand I can do what I want to do.  And so far it is not costing me any money by having to buy your service.  Thanks for that saving.

    Can I suggest you do some YouTube on this as there is very little out there I could find and even your own KB is very limited when compared to other services.

     

     

     

     

     

    0
    Comment actions Permalink
  • cbetta

    Happy to see this worked out for you. And yes we will be working on some videos in the coming months.

    0
    Comment actions Permalink

Please sign in to leave a comment.