Confusion about creating an App User with the box-node-sdk

Answered
New post

Comments

4 comments

  • kendomen

    It was confusing to me too.

     

    So basically, I did this:

    1.  Steps 1-3 of https://docs.box.com/docs/app-auth

    2.  I didn't try to create the jwt assertion manually - I used the sdk. 

    3.  Then I ran the app: https://github.com/kendomen/BoxJavaJWTExamples/blob/master/src/com/nike/box/CreateAppUser.java

     

    0
    Comment actions Permalink
  • Box Product Support

    I solved it directly through box-node-sdk. While there is no "add app user" api call (e.g. like client.users.add), they do provide generic calls. So I used it like this:

     

    client.post('/users', {body: {name: "App User Name", "is_platform_access_only": true}}, function(err, response) {

    if (!err) {
    console.log("User create:");
    console.log(response.body);
    } else {
    console.log("Error creating user");
    }

    });

    I authenticated like this:

     

    var sdk = new BoxSDK({
    clientID: 'CLIENT_ID',
    clientSecret: 'CLIENT_SECRET',
    appAuth: {
    keyID: 'KEY_ID',
    privateKey: 'PRIVATE_KEY',
    passphrase: 'PRIVATE_PASS'
    }
    });

    client = sdk.getAppAuthClient('enterprise', 'ENTERPRISE_ID');

     CLIENT_ID, CLIENT_SECRET and ENTERPRISE_ID from the Box portal, while KEY_ID, PRIVATE_KEY and PRIVATE_PASS is from creating the RSA keypair. PRIVATE_KEY is the whole .pem file and KEY_ID is from the Box-portal.

    0
    Comment actions Permalink
  • exnerr

    Thank you so much! This did the trick.

     

    Something to keep in mind: The setting for "Application Access" needs to be set to 'Enterprise' for this to work.  If you change the setting, you'll need to re-authorize the App in your enterprise.

    0
    Comment actions Permalink
  • kukkapilla

    How can we do this with JWT without SDK? switch to another user , any sample code will be appreciated.

    0
    Comment actions Permalink

Please sign in to leave a comment.