@@ -26,19 +26,19 @@ and can only be used with your own account. Therefore, they're only useful for
2626testing an app and aren't suitable for production. You can obtain a developer
2727token from your application's [ developer console] [ dev_console ] page.
2828
29- To create a ` Client ` with a developer token, construct an ` DeveloperTokenAuth `
29+ To create a ` BoxClient ` with a developer token, construct an ` BoxDeveloperTokenAuth `
3030object with the ` token ` set to the developer token and construct the client with that.
3131
3232<!-- sample x_auth init_with_dev_token -->
3333
3434``` js
35- const { Client } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
35+ const { BoxClient } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
3636const {
37- DeveloperTokenAuth ,
38- } = require (' box-typescript-sdk-gen/lib/developerTokenAuth.js' );
37+ BoxDeveloperTokenAuth ,
38+ } = require (' box-typescript-sdk-gen/lib/developerTokenAuth.generated. js' );
3939
40- const auth = new DeveloperTokenAuth ({ token: ' DEVELOPER_TOKEN_GOES_HERE' });
41- const client = new Client ({ auth });
40+ const auth = new BoxDeveloperTokenAuth ({ token: ' DEVELOPER_TOKEN_GOES_HERE' });
41+ const client = new BoxClient ({ auth });
4242
4343const me = await client .users .getUserMe ();
4444console .log (` My user ID is ${ me .id } ` );
@@ -63,17 +63,20 @@ not accessible in any other account by default, and vice versa.
6363If you generated your public and private keys automatically through the
6464[ Box Developer Console] [ dev_console ] , you can use the JSON file created there
6565to configure your SDK instance and create a client to make calls as the
66- Service Account. Call one of static ` JwtAuth ` method:
66+ Service Account. Call one of static ` BoxJwtAuth ` method:
6767` JwtConfig.fromConfigFile(configFilePath) ` and pass JSON file local path
6868or ` JwtConfig.fromConfigJsonString(configJsonString) ` and pass JSON config file content as string.
6969
7070``` js
71- const { Client } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
72- const { JwtAuth , JwtConfig } = require (' box-typescript-sdk-gen/lib/jwtAuth.js' );
71+ const { BoxClient } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
72+ const {
73+ BoxJwtAuth ,
74+ JwtConfig ,
75+ } = require (' box-typescript-sdk-gen/lib/jwtAuth.js' );
7376
7477const jwtConfig = JwtConfig .fromConfigFile (' /path/to/settings.json' );
75- const jwtAuth = new JwtAuth ({ config: jwtConfig });
76- const client = new Client ({ auth: jwtAuth });
78+ const jwtAuth = new BoxJwtAuth ({ config: jwtConfig });
79+ const client = new BoxClient ({ auth: jwtAuth });
7780
7881const me = await client .users .getUserMe ();
7982console .log (` My user ID is ${ me .id } ` );
@@ -82,8 +85,11 @@ console.log(`My user ID is ${me.id}`);
8285Otherwise, you'll need to provide the necessary configuration fields directly to the ` JwtConfig ` constructor:
8386
8487``` js
85- const { Client } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
86- const { JwtAuth , JwtConfig } = require (' box-typescript-sdk-gen/lib/jwtAuth.js' );
88+ const { BoxClient } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
89+ const {
90+ BoxJwtAuth ,
91+ JwtConfig ,
92+ } = require (' box-typescript-sdk-gen/lib/jwtAuth.js' );
8793
8894const jwtConfig = new JwtConfig ({
8995 clientId: ' YOUR_CLIENT_ID' ,
@@ -93,8 +99,8 @@ const jwtConfig = new JwtConfig({
9399 privateKeyPassphrase: ' PASSPHRASE' ,
94100 enterpriseId: ' YOUR_ENTERPRISE_ID' ,
95101});
96- const jwtAuth = new JwtAuth ({ config: jwtConfig });
97- const serviceAccountClient = new Client ({ auth: jwtAuth });
102+ const jwtAuth = new BoxJwtAuth ({ config: jwtConfig });
103+ const serviceAccountClient = new BoxClient ({ auth: jwtAuth });
98104```
99105
100106### Authenticate user
@@ -111,22 +117,28 @@ Clients for making calls as an App User can be created with the same JSON JWT co
111117a user ID you want to authenticate.
112118
113119``` js
114- const { Client } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
115- const { JwtAuth , JwtConfig } = require (' box-typescript-sdk-gen/lib/jwtAuth.js' );
120+ const { BoxClient } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
121+ const {
122+ BoxJwtAuth ,
123+ JwtConfig ,
124+ } = require (' box-typescript-sdk-gen/lib/jwtAuth.js' );
116125
117126const jwtConfig = JwtConfig .fromConfigFile (' /path/to/settings.json' );
118- const jwtAuth = new JwtAuth ({ config: jwtConfig });
127+ const jwtAuth = new BoxJwtAuth ({ config: jwtConfig });
119128jwtAuth .asUser (' USER_ID' );
120- const userClient = new Client ({ auth: jwtAuth });
129+ const userClient = new BoxClient ({ auth: jwtAuth });
121130```
122131
123132Alternatively, clients for making calls as an App User can be created with the same ` JwtConfig `
124133constructor as in the above examples, similarly to creating a Service Account client. Simply pass the
125134` userId ` instead of ` enterpriseId ` when constructing the auth config instance:
126135
127136``` js
128- const { Client } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
129- const { JwtAuth , JwtConfig } = require (' box-typescript-sdk-gen/lib/jwtAuth.js' );
137+ const { BoxClient } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
138+ const {
139+ BoxJwtAuth ,
140+ JwtConfig ,
141+ } = require (' box-typescript-sdk-gen/lib/jwtAuth.js' );
130142
131143const jwtConfig = new JwtConfig ({
132144 clientId: ' YOUR_CLIENT_ID' ,
@@ -136,8 +148,8 @@ const jwtConfig = new JwtConfig({
136148 privateKeyPassphrase: ' PASSPHRASE' ,
137149 userId: ' USER_ID' ,
138150});
139- const jwtAuth = new JwtAuth ({ config: jwtConfig });
140- const userClient = new Client ({ auth: jwtAuth });
151+ const jwtAuth = new BoxJwtAuth ({ config: jwtConfig });
152+ const userClient = new BoxClient ({ auth: jwtAuth });
141153```
142154
143155[ jwt_guide ] : https://developer.box.com/guides/authentication/jwt/jwt-setup/
@@ -155,16 +167,16 @@ and secret with enterprise or user ID, which allows you to work using service or
155167You can use ` CCGAuth ` to initialize a client object the same way as for other authentication types:
156168
157169``` js
158- const { Client } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
159- const { CcgAuth } = require (' box-typescript-sdk-gen/lib/ccgAuth.js' );
170+ const { BoxClient } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
171+ const { BoxCcgAuth } = require (' box-typescript-sdk-gen/lib/ccgAuth.js' );
160172
161173const ccgConfig = {
162174 userId: ' YOUR_USER_ID' ,
163175 clientId: ' YOUR_CLIENT_ID' ,
164176 clientSecret: ' YOUR_CLIENT_SECRET' ,
165177};
166- const ccgAuth = new CcgAuth ({ config: ccgConfig });
167- const client = new Client ({ auth: ccgAuth });
178+ const ccgAuth = new BoxCcgAuth ({ config: ccgConfig });
179+ const client = new BoxClient ({ auth: ccgAuth });
168180
169181const me = await client .users .getUserMe ();
170182console .log (` My user ID is ${ me .id } ` );
@@ -181,16 +193,16 @@ are not accessible in any other account by default, and vice versa.
181193To obtain service account you will have to provide enterprise ID with client id and secret:
182194
183195``` js
184- const { Client } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
185- const { CcgAuth } = require (' box-typescript-sdk-gen/lib/ccgAuth.js' );
196+ const { BoxClient } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
197+ const { BoxCcgAuth } = require (' box-typescript-sdk-gen/lib/ccgAuth.js' );
186198
187199const ccgConfig = {
188200 enterpriseId: ' YOUR_ENTERPRISE_ID' ,
189201 clientId: ' YOUR_CLIENT_ID' ,
190202 clientSecret: ' YOUR_CLIENT_SECRET' ,
191203};
192- const ccgAuth = new CcgAuth ({ config: ccgConfig });
193- const client = new Client ({ auth: ccgAuth });
204+ const ccgAuth = new BoxCcgAuth ({ config: ccgConfig });
205+ const client = new BoxClient ({ auth: ccgAuth });
194206```
195207
196208### Obtaining User token
@@ -202,16 +214,16 @@ select `Generate user access tokens`. Do not forget to re-authorize application
202214To obtain user account you will have to provide user ID with client id and secret.
203215
204216``` js
205- const { Client } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
206- const { CcgAuth } = require (' box-typescript-sdk-gen/lib/ccgAuth.js' );
217+ const { BoxClient } = require (' box-typescript-sdk-gen/lib/client.generated.js' );
218+ const { BoxCcgAuth } = require (' box-typescript-sdk-gen/lib/ccgAuth.js' );
207219
208220const ccgConfig = {
209221 userId: ' YOUR_USER_ID' ,
210222 clientId: ' YOUR_CLIENT_ID' ,
211223 clientSecret: ' YOUR_CLIENT_SECRET' ,
212224};
213- const ccgAuth = new CcgAuth ({ config: ccgConfig });
214- const client = new Client ({ auth: ccgAuth });
225+ const ccgAuth = new BoxCcgAuth ({ config: ccgConfig });
226+ const client = new BoxClient ({ auth: ccgAuth });
215227```
216228
217229### Switching between Service Account and User
@@ -248,13 +260,16 @@ browser or web view) in order to obtain an auth code.
248260<!-- sample get_authorize -->
249261
250262``` js
251- const { OAuth , OAuthConfig } = require (' box-typescript-sdk-gen/lib/oauth.js' );
263+ const {
264+ BoxOAuth ,
265+ OAuthConfig ,
266+ } = require (' box-typescript-sdk-gen/lib/oauth.js' );
252267
253268const config = {
254269 clientId: ' OAUTH_CLIENT_ID' ,
255270 clientSecret: ' OAUTH_CLIENT_SECRET' ,
256271};
257- const oauth = new OAuth ({ config: config });
272+ const oauth = new BoxOAuth ({ config: config });
258273
259274// the URL to redirect the user to
260275var authorize_url = oauth .getAuthorizeUrl ();
@@ -286,7 +301,7 @@ const config = {
286301 clientId: ' OAUTH_CLIENT_ID' ,
287302 clientSecret: ' OAUTH_CLIENT_SECRET' ,
288303};
289- const oauth = new OAuth ({ config: config });
304+ const oauth = new BoxOAuth ({ config: config });
290305```
291306
292307## Custom storage
@@ -300,5 +315,5 @@ const config = {
300315 clientSecret: ' OAUTH_CLIENT_SECRET' ,
301316 tokenStorage: new MyCustomTokenStorage (),
302317};
303- const oauth = new OAuth ({ config: config });
318+ const oauth = new BoxOAuth ({ config: config });
304319```
0 commit comments