Skip to content

Commit 413058e

Browse files
feat: Expose token storage for authentication classes (box/box-codegen#682) (#435)
1 parent dc9a21f commit 413058e

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "3d68c3f", "specHash": "c303afc", "version": "1.8.0" }
1+
{ "engineHash": "ff32ae8", "specHash": "c303afc", "version": "1.8.0" }

Box.Sdk.Gen/Box/CcgAuth/BoxCcgAuth.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class BoxCcgAuth : IAuthentication {
1616
/// <summary>
1717
/// An object responsible for storing token. If no custom implementation provided, the token will be stored in memory.
1818
/// </summary>
19-
internal ITokenStorage TokenStorage { get; }
19+
public ITokenStorage TokenStorage { get; }
2020

2121
/// <summary>
2222
/// The ID of the user or enterprise to authenticate as. If not provided, defaults to the enterprise ID if set, otherwise defaults to the user ID.

Box.Sdk.Gen/Box/DeveloperTokenAuth/BoxDeveloperTokenAuth.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class BoxDeveloperTokenAuth : IAuthentication {
1818
/// <summary>
1919
/// An object responsible for storing token. If no custom implementation provided, the token will be stored in memory.
2020
/// </summary>
21-
internal ITokenStorage TokenStorage { get; }
21+
public ITokenStorage TokenStorage { get; }
2222

2323
public BoxDeveloperTokenAuth(string token, DeveloperTokenConfig? config = default) {
2424
Token = token;

Box.Sdk.Gen/Box/JwtAuth/BoxJwtAuth.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class BoxJwtAuth : IAuthentication {
1717
/// <summary>
1818
/// An object responsible for storing token. If no custom implementation provided, the token will be stored in memory.
1919
/// </summary>
20-
internal ITokenStorage TokenStorage { get; }
20+
public ITokenStorage TokenStorage { get; }
2121

2222
/// <summary>
2323
/// The ID of the user or enterprise to authenticate as. If not provided, defaults to the enterprise ID if set, otherwise defaults to the user ID.

Box.Sdk.Gen/Box/Oauth/BoxOAuth.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class BoxOAuth : IAuthentication {
1616
/// <summary>
1717
/// An object responsible for storing token. If no custom implementation provided, the token will be stored in memory.
1818
/// </summary>
19-
internal ITokenStorage TokenStorage { get; }
19+
public ITokenStorage TokenStorage { get; }
2020

2121
public BoxOAuth(OAuthConfig config) {
2222
Config = config;

docs/Authentication.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,20 +257,17 @@ var client = new BoxClient(auth: auth);
257257

258258
### Injecting existing token into BoxOAuth
259259

260-
If you already have an access token and refresh token, you can initialize `BoxOAuth` with them.
261-
You can achieve this by feeding `BoxOAuth` with token storage containing the token.
262-
This can be useful when you want to reuse the token between runs of your application.
260+
If you already have an access token and refresh token, you can inject them into the `BoxOAuth` token storage
261+
to avoid repeating the authentication process. This can be useful when you want to reuse the token
262+
between runs of your application.
263263

264264
```c#
265265
var accessToken = new AccessToken
266266
{
267267
AccessTokenField = "<ACCESS_TOKEN>",
268268
RefreshToken = "<REFRESH_TOKEN>"
269269
};
270-
var tokenStorage = new InMemoryTokenStorage();
271-
await tokenStorage.StoreAsync(accessToken);
272-
var config = new OAuthConfig(clientId: "YOUR_CLIENT_ID", clientSecret: "YOUR_CLIENT_SECRET", tokenStorage: tokenStorage);
273-
var auth = new BoxOAuth(config: config);
270+
await auth.tokenStorage.StoreAsync(accessToken);
274271
var client = new BoxClient(auth: auth);
275272
```
276273

0 commit comments

Comments
 (0)