My Apps

    Using in SDKs

    Using in SDKs

    The SDKs have direct support for JWT and OAuth 2.0 authentication, yet in some cases your application might need to provide an Access Token to the SDK directly.

    Java
    BoxAPIConnection api = new BoxAPIConnection("YOUR-CLIENT-ID",
        "YOUR-CLIENT-SECRET", "YOUR-ACCESS-TOKEN", "YOUR-REFRESH-TOKEN");
    Python
    from boxsdk import Client, OAuth2
    
    oauth = OAuth2(
        client_id='YOUR_CLIENT_ID',
        client_secret='YOUR_CLIENT_SECRET',
        access_token='ACCESS_TOKEN',
        refresh_token='REFRESH_TOKEN',
    )
    
    client = Client(auth)
    
    user = client.user().get()
    print('User ID is {0}'.format(user.id))

    Developer Token

    Similarly, developer tokens can be used directly in SDKs without needing any further SDK configuration.

    .NET
    var config = new BoxConfig("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", new Uri("http://localhost"));
    var session = new OAuthSession("YOUR_DEVELOPER_TOKEN", "N/A", 3600, "bearer");
    var client = new BoxClient(config, session);
    Java
    BoxAPIConnection api = new BoxAPIConnection("YOUR-DEVELOPER-TOKEN");
    Python
    from boxsdk import Client, OAuth2
    
    auth = OAuth2(
        client_id='YOUR_CLIENT_ID',
        client_secret='YOUR_CLIENT_SECRET',
        access_token='DEVELOPER_TOKEN_GOES_HERE',
    )
    client = Client(auth)
    me = client.user().get()
    print('My user ID is {0}'.format(me.id))
    Node
    var BoxSDK = require('box-node-sdk');
    var sdk = new BoxSDK({
    	clientID: 'YOUR-CLIENT-ID',
    	clientSecret: 'YOUR-CLIENT_SECRET'
    });
    
    var client = sdk.getBasicClient('YOUR-DEVELOPER-TOKEN');

    App Token

    When using App Token authentication it is possible to directly pass the App Token to the SDKs.

    .NET
    var config = new BoxConfig("YOUR_CLIENT_ID", "N/A", new Uri("http://localhost"));
    var session = new OAuthSession("YOUR_APP_TOKEN", "N/A", 3600, "bearer");
    var client = new BoxClient(config, session);
    Java
    BoxTransactionalAPIConnection api = new BoxTransactionalAPIConnection("YOUR-ACCESS-TOKEN");
    Python
    from boxsdk import Client, OAuth2
    
    auth = OAuth2(access_token='APP_ACCESS_TOKEN_GOES_HERE')
    client = Client(auth)
    Node
    var BoxSDK = require('box-node-sdk');
    var sdk = new BoxSDK({
    	clientID: 'YOUR-CLIENT-ID',
    	clientSecret: 'unused'
    });
    
    var client = sdk.getBasicClient('YOUR-APP-TOKEN');