Skip to content

Commit

Permalink
Rollback docs to current release version
Browse files Browse the repository at this point in the history
  • Loading branch information
mwwoda committed Oct 13, 2021
1 parent c29b0a7 commit f4ec3ba
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 88 deletions.
57 changes: 10 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ Prerequisites
* Visual Studio 2017
* .NET Core SDK (if running .NET Core samples)

Getting Started Docs: https://developer.box.com/guides/tooling/sdks/dotnet/

Quick Start
-----------

Expand All @@ -35,7 +33,7 @@ If you haven't already created an app in Box go to https://developer.box.com/ an

#### Using a Developer Token (generate one in your app admin console; they last for 60 minutes)
```c#
var config = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, new Uri("http://localhost")).Build();
var config = new BoxConfig(<Client_Id>, <Client_Secret>, new Uri("http://localhost"));
var session = new OAuthSession(<Developer_Token>, "NOT_NEEDED", 3600, "bearer");
client = new BoxClient(config, session);
```
Expand All @@ -58,13 +56,13 @@ Allow Box Managed Users to share and collaboration with external users via Box a

##### Configure
```c#
var boxConfig = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, <Enterprise_Id>, <Private_Key>, <JWT_Private_Key_Password>, <JWT_Public_Key_Id>). Build();
var boxConfig = new BoxConfig(<Client_Id>, <Client_Secret>, <Enterprise_Id>, <Private_Key>, <JWT_Private_Key_Password>, <JWT_Public_Key_Id>);
var boxJWT = new BoxJWTAuth(boxConfig);
```

##### Authenticate
```c#
var adminToken = await boxJWT.AdminTokenAsync(); //valid for 60 minutes so should be cached and re-used
var adminToken = boxJWT.AdminToken(); //valid for 60 minutes so should be cached and re-used
var adminClient = boxJWT.AdminClient(adminToken);
```

Expand All @@ -75,7 +73,7 @@ var userRequest = new BoxUserRequest() { Name = "test appuser", IsPlatformAccess
var appUser = await adminClient.UsersManager.CreateEnterpriseUserAsync(userRequest);

//get a user client
var userToken = await boxJWT.UserTokenAsync(appUser.Id); //valid for 60 minutes so should be cached and re-used
var userToken = boxJWT.UserToken(appUser.Id); //valid for 60 minutes so should be cached and re-used
var userClient = boxJWT.UserClient(userToken, appUser.Id);

//for example, look up the app user's details
Expand All @@ -91,7 +89,7 @@ This is a three-legged authentication process to allow managed user and external
##### Configure
Set your configuration parameters and initialize the client:
```c#
var config = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, <Redirect_Uri>).Build();
var config = new BoxConfig(<Client_Id>, <Client_Secret>, <Redirect_Uri>);
var client = new BoxClient(config);
```

Expand Down Expand Up @@ -134,7 +132,7 @@ this method of aythentication, simply create a client with only the API key and
access token provided:

```c#
var config = new BoxConfigBuilder(<API_KEY>, "", new Uri("http://localhost")).Build();
var config = new BoxConfig(<API_KEY>, "", new Uri("http://localhost"));
var session = new OAuthSession(<PRIMARY OR SECONDARY TOKEN>, "NOT_NEEDED", 3600, "bearer");
client = new BoxClient(config, session);
```
Expand Down Expand Up @@ -276,7 +274,7 @@ var results = await client.SearchManager.SearchAsync(mdFilters: new List<BoxMeta
If you have an admin token with appropriate permissions, you can make API calls in the context of a managed user. In order to do this you must request Box.com to activate As-User functionality for your API key (see developer site for instructions).

```c#
var config = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, <Redirect_Uri).Build();
var config = new BoxConfig(<Client_Id>, <Client_Secret>, <Redirect_Uri);
var auth = new OAuthSession(<Your_Access_Token>, <Your_Refresh_Token>, 3600, "bearer");

var userId = "12345678"
Expand All @@ -291,10 +289,10 @@ var items = await userClient.FoldersManager.GetFolderItemsAsync("0", 500);
Using the admin token we can make a call to retrieve all users or a specific user

```cs
var boxConfig = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, <Enterprise_Id>, <Private_Key>, <JWT_Private_Key_Password>, <JWT_Public_Key_Id>). Build();
var boxConfig = new BoxConfig(<Client_Id>, <Client_Secret>, <Enterprise_Id>, <Private_Key>, <JWT_Private_Key_Password>, <JWT_Public_Key_Id>);
var boxJWT = new BoxJWTAuth(boxConfig);

var adminToken = await boxJWT.AdminTokenAsync();
var adminToken = boxJWT.AdminToken();
var adminClient = boxJWT.AdminClient(adminToken);

var boxUsers = await adminClient.UsersManager.GetEnterpriseUsersAsync();
Expand Down Expand Up @@ -326,47 +324,12 @@ foreach(BoxItem item in boxFolderItemsList)
#### Suppressing Notifications
If you are making administrative API calls (that is, your application has “Manage an Enterprise” scope, and the user making the API call is a co-admin with the correct "Edit settings for your company" permission) then you can suppress both email and webhook notifications.
```c#
var config = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, <Redirect_Uri).Build();
var config = new BoxConfig(<Client_Id>, <Client_Secret>, <Redirect_Uri);
var auth = new OAuthSession(<Your_Access_Token>, <Your_Refresh_Token>, 3600, "bearer");

var adminClient = new BoxClient(config, auth, suppressNotifications: true);
```

#### Constructing API Calls Manually
The SDK also exposes low-level request methods for constructing your own API calls. These can be useful for adding your own API calls that aren't yet explicitly supported by the SDK.

To make a custom api call you need to provide implementation for `BoxResourceManager`.

```c#
public class BoxFolderHintsManager : BoxResourceManager
{
public BoxFolderHintsManager(IBoxConfig config, IBoxService service, IBoxConverter converter, IAuthRepository auth, string asUser = null, bool? suppressNotifications = null) : base(config, service, converter, auth, asUser, suppressNotifications) { }

public async Task<MyCustomReturnObject> GetFolderItemsWithHintsAsync(string folderId, string xRepHints)
{
BoxRequest request = new BoxRequest(_config.FoldersEndpointUri, string.Format(Constants.ItemsPathString, folderId))
.Method(RequestMethod.Get)
.Param(ParamFields, "representations")
.Header(Constants.RequestParameters.XRepHints, xRepHints);

return await ToResponseAsync<MyCustomReturnObject>(request).ConfigureAwait(false);
}
}
```

You need to first register your custom `BoxResourceManager`, then you can use it as any other SDK manager.

```c#
client = boxJWT.UserClient(userToken, userId);
client.AddResourcePlugin<BoxFolderHintsManager>();

string folderId = "11111";
string xRepHints = "[jpg?dimensions=32x32][jpg?dimensions=94x94]";

var boxFolderHintsManager = client.ResourcePlugins.Get<BoxFolderHintsManager>();
var response = await boxFolderHintsManager.GetFolderItemsWithHintsAsync(folderId, xRepHints);
```

File/Folder Picker
------------------
The Box Windows SDK includes a user control that allows developers an easy way to drop in a file and or folder picker in just one line of code
Expand Down
22 changes: 11 additions & 11 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The following example creates an API client with a developer token:

<!-- sample x_auth init_with_dev_token -->
```c#
var config = new BoxConfigBuilder("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", new Uri("http://localhost")).Build();
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);
```
Expand All @@ -62,20 +62,20 @@ Service Account:

<!-- sample x_auth init_with_jwt_enterprise -->
```c#
var config = BoxConfigBuilder.CreateFromJsonString(jsonConfig).Build();
var config = BoxConfig.CreateFromJsonString(jsonConfig);
var session = new BoxJWTAuth(config);
var adminToken = await session.AdminTokenAsync(); //valid for 60 minutes so should be cached and re-used
var adminToken = session.AdminToken(); //valid for 60 minutes so should be cached and re-used
BoxClient adminClient = session.AdminClient(adminToken);
```

Otherwise, you'll need to provide the necessary configuration fields directly
to the `BoxConfigBuilder` constructor:
to the `BoxConfig` constructor:

<!-- sample x_auth init_with_jwt_enterprise_with_config -->
```c#
var boxConfig = new BoxConfigBuilder("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "YOUR_ENTERPRISE_ID", "ENCRYPTED_PRIVATE_KEY", "PRIVATE_KEY_PASSWORD", "PUBLIC_KEY_ID").Build();
var boxConfig = new BoxConfig("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "YOUR_ENTERPRISE_ID", "ENCRYPTED_PRIVATE_KEY", "PRIVATE_KEY_PASSWORD", "PUBLIC_KEY_ID");
var boxJWT = new BoxJWTAuth(boxConfig);
var adminToken = await boxJWT.AdminTokenAsync(); //valid for 60 minutes so should be cached and re-used
var adminToken = boxJWT.AdminToken(); //valid for 60 minutes so should be cached and re-used
BoxClient adminClient = boxJWT.AdminClient(adminToken);
adminClient.Auth.SessionAuthenticated += delegate(object o, SessionAuthenticatedEventArgs e)
{
Expand All @@ -99,7 +99,7 @@ instance as in the above examples, similarly to creating a Service Account clien
<!-- sample x_auth init_with_jwt_with_user_id -->
```c#
var appUserId = "12345";
var userToken = await boxJWT.UserTokenAsync(appUserID); //valid for 60 minutes so should be cached and re-used
var userToken = boxJWT.UserToken(appUserID); //valid for 60 minutes so should be cached and re-used
BoxClient appUserClient = boxJWT.UserClient(userToken, appUserId);
appUserClient.Auth.SessionAuthenticated += delegate(object o, SessionAuthenticatedEventArgs e)
{
Expand Down Expand Up @@ -128,7 +128,7 @@ client secret to establish an API connection. The `BoxClient` will
automatically refresh the access token as needed.

```c#
var config = new BoxConfigBuilder("CLIENT_ID", "CLIENT_SECRET", new System.Uri("YOUR_REDIRECT_URL")).Build();
var config = new BoxConfig("CLIENT_ID", "CLIENT_SECRET", new System.Uri("YOUR_REDIRECT_URL"));
var client = new BoxClient(config);
OAuthSession session = // Create session from custom implementation
var client = new BoxClient(config, session);
Expand All @@ -155,7 +155,7 @@ simply create a basic client with that token:

<!-- sample x_auth init_with_app_token -->
```c#
var config = new BoxConfigBuilder("YOUR_CLIENT_ID", "N/A", new Uri("http://localhost")).Build();
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);
```
Expand Down Expand Up @@ -194,13 +194,13 @@ scope, restricted to a single file, suitable for the
```c#
var exchanger = new TokenExchange(client.Auth.Session.AccessToken, "item_preview");
exchanger.SetResource("https://api.box.com/2.0/files/123456789");
string downscopedToken = await exchanger.ExchangeAsync();
string downscopedToken = exchanger.Exchange();
```

To exchange the client's token for one with scopes to upload and delete items, but not to view their contents,
which would be suitable for an less-trusted server-side process;
```c#
var scopes = new List<string>() { "item_upload", "item_download" };
var exchanger = new TokenExchange(client.Auth.Session.AccessToken, scopes);
string downscopedToken = await exchanger.ExchangeAsync();
string downscopedToken = exchanger.Exchange();
```
30 changes: 0 additions & 30 deletions docs/terms-of-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Box Platform.
- [Update a Terms of Service for an Enterprise](#update-a-terms-of-service-for-an-enterprise)
- [Get a Terms of Service By ID](#get-a-terms-of-service-by-id)
- [Get Terms of Service for an Enterprise](#get-terms-of-service-for-an-enterprise)
- [Create User Status on Terms of Service](#create-user-status-on-terms-of-service)
- [Update User Status on Terms of Service](#update-user-status-on-terms-of-service)
- [Get Terms of Service Status for User](#get-terms-of-service-status-for-user)

Expand Down Expand Up @@ -79,35 +78,6 @@ BoxTermsOfServiceCollection<BoxTermsOfService> termsOfService = await client.Ter
.GetTermsOfServicesAsync();
```

Create User Status on Terms of Service
--------------------------------------

For create user status on a terms of service call the
`TermsOfServiceManager.CreateBoxTermsOfServiceUserStatusesAsync(BoxTermsOfServiceUserStatusCreateRequest termsOfServiceUserStatusCreateRequest)`

You can only create a user status on a terms of service if the user has never accepted/declined a terms of service.
If they have then you will need to make the update call..

<!-- sample post_terms_of_service_user_statuses -->
```c#
var createStatusRequest = new BoxTermsOfServiceUserStatusCreateRequest()
{
TermsOfService = new BoxRequestEntity()
{
Id = "11111",
Type = BoxType.terms_of_service
},
User = new BoxRequestEntity()
{
Id = "22222",
Type = BoxType.user
},
IsAccepted = true
};
BoxTermsOfServiceUserStatuses termsOfServiceUserStatuses =
await client.TermsOfServiceManager.CreateBoxTermsOfServiceUserStatusesAsync(createStatusRequest);
```

Update User Status on Terms of Service
--------------------------------------

Expand Down

0 comments on commit f4ec3ba

Please sign in to comment.