Skip to content

Commit 464bc25

Browse files
fix: Ensure AuthorizationManager in authentication classes is initialized with NetworkSession object (box/box-codegen#469) (#140)
1 parent 28b266c commit 464bc25

File tree

6 files changed

+261
-231
lines changed

6 files changed

+261
-231
lines changed

.codegen.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "f3d7de8", "specHash": "1698c95", "version": "0.5.3" }
1+
{ "engineHash": "ce205f7", "specHash": "1698c95", "version": "0.5.3" }

docs/authentication.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object with the `token` set to the developer token and construct the client with
4141
const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js');
4242
const {
4343
BoxDeveloperTokenAuth,
44-
} = require('box-typescript-sdk-gen/lib/developerTokenAuth.generated.js');
44+
} = require('box-typescript-sdk-gen/lib/box/developerTokenAuth.generated.js');
4545

4646
const auth = new BoxDeveloperTokenAuth({ token: 'DEVELOPER_TOKEN_GOES_HERE' });
4747
const client = new BoxClient({ auth });
@@ -78,7 +78,7 @@ const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js');
7878
const {
7979
BoxJwtAuth,
8080
JwtConfig,
81-
} = require('box-typescript-sdk-gen/lib/jwtAuth.generated.js');
81+
} = require('box-typescript-sdk-gen/lib/box/jwtAuth.generated.js');
8282

8383
const jwtConfig = JwtConfig.fromConfigFile('/path/to/settings.json');
8484
const jwtAuth = new BoxJwtAuth({ config: jwtConfig });
@@ -95,7 +95,7 @@ const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js');
9595
const {
9696
BoxJwtAuth,
9797
JwtConfig,
98-
} = require('box-typescript-sdk-gen/lib/jwtAuth.generated.js');
98+
} = require('box-typescript-sdk-gen/lib/box/jwtAuth.generated.js');
9999

100100
const jwtConfig = new JwtConfig({
101101
clientId: 'YOUR_CLIENT_ID',
@@ -127,7 +127,7 @@ const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js');
127127
const {
128128
BoxJwtAuth,
129129
JwtConfig,
130-
} = require('box-typescript-sdk-gen/lib/jwtAuth.generated.js');
130+
} = require('box-typescript-sdk-gen/lib/box/jwtAuth.generated.js');
131131

132132
const jwtConfig = JwtConfig.fromConfigFile('/path/to/settings.json');
133133
const jwtAuth = new BoxJwtAuth({ config: jwtConfig });
@@ -144,7 +144,7 @@ const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js');
144144
const {
145145
BoxJwtAuth,
146146
JwtConfig,
147-
} = require('box-typescript-sdk-gen/lib/jwtAuth.generated.js');
147+
} = require('box-typescript-sdk-gen/lib/box/jwtAuth.generated.js');
148148

149149
const jwtConfig = new JwtConfig({
150150
clientId: 'YOUR_CLIENT_ID',
@@ -177,7 +177,7 @@ const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js');
177177
const {
178178
BoxCcgAuth,
179179
CcgConfig,
180-
} = require('box-typescript-sdk-gen/lib/ccgAuth.generated.js');
180+
} = require('box-typescript-sdk-gen/lib/box/ccgAuth.generated.js');
181181

182182
const ccgConfig = new CcgConfig({
183183
userId: 'YOUR_USER_ID',
@@ -206,7 +206,7 @@ const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js');
206206
const {
207207
BoxCcgAuth,
208208
CcgConfig,
209-
} = require('box-typescript-sdk-gen/lib/ccgAuth.generated.js');
209+
} = require('box-typescript-sdk-gen/lib/box/ccgAuth.generated.js');
210210

211211
const ccgConfig = new CcgConfig({
212212
enterpriseId: 'YOUR_ENTERPRISE_ID',
@@ -230,7 +230,7 @@ const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js');
230230
const {
231231
BoxCcgAuth,
232232
CcgConfig,
233-
} = require('box-typescript-sdk-gen/lib/ccgAuth.generated.js');
233+
} = require('box-typescript-sdk-gen/lib/box/ccgAuth.generated.js');
234234

235235
const ccgConfig = new CcgConfig({
236236
userId: 'YOUR_USER_ID',
@@ -283,7 +283,7 @@ browser or web view) in order to obtain an auth code.
283283
const {
284284
BoxOAuth,
285285
OAuthConfig,
286-
} = require('box-typescript-sdk-gen/lib/oauth.generated.js');
286+
} = require('box-typescript-sdk-gen/lib/box/oauth.generated.js');
287287

288288
const config = new OAuthConfig({
289289
clientId: 'OAUTH_CLIENT_ID',
@@ -310,9 +310,11 @@ await oauth.getTokensAuthorizationCodeGrant('code');
310310
# Revoke token
311311

312312
Access tokens for a client can be revoked when needed. This call invalidates old token.
313-
For CCGAuth and JWTAuth you can still reuse the `auth` object to retrieve a new token. If you make any new call after revoking the token,
314-
a new token will be automatically retrieved.
315-
For OAuth it would be necessary to manually go through the authentication process again.
313+
For BoxCcgAuth and BoxJwtAuth you can still reuse the `auth` object to retrieve a new token.
314+
If you make any new call after revoking the token, a new token will be automatically retrieved.
315+
For BoxOAuth it would be necessary to manually go through the authentication process again.
316+
For BoxDeveloperTokenAuth, it is necessary to provide a DeveloperTokenConfig during initialization,
317+
containing the client ID and client secret.
316318

317319
To revoke current client's tokens in the storage use the following code:
318320

@@ -338,7 +340,7 @@ If you want to learn more about available scopes please go [here](https://develo
338340

339341
For example to get a new token with only `item_preview` scope, restricted to a single file, suitable for the
340342
[Content Preview UI Element](https://developer.box.com/en/guides/embed/ui-elements/preview/) you can use the following code.
341-
You can also initialize `DeveloperTokenAuth` with the retrieved access token and use it to create a new Client.
343+
You can also initialize `BoxDeveloperTokenAuth` with the retrieved access token and use it to create a new Client.
342344

343345
<!-- sample post_oauth2_token downscope_token -->
344346

0 commit comments

Comments
 (0)