C# Class Box.V2.JWTAuth.BoxJWTAuth

Box’s new authentication model allows applications to authenticate directly to Box using a JSON Web Token (JWT) signed with an RSA key. This authentication method is meant for server-to-server applications and replaces the first leg of the standard 3-legged OAuth 2.0 process in which users grant an application authorization to access their Box account.
https://docs.box.com/docs/getting-started-box-platform
Show file Open project: box/box-windows-sdk-v2 Class Usage Examples

Public Methods

Method Description
AdminClient ( string adminToken, string asUser = null, bool suppressNotifications = null ) : BoxClient

Create admin BoxClient using an admin access token

AdminToken ( ) : string

Get admin token by posting data to auth url

BoxJWTAuth ( IBoxConfig boxConfig ) : Box.V2.Auth

Constructor for JWT authentication

Session ( string token ) : OAuthSession

Create OAuth session from token

UserClient ( string userToken, string userId ) : BoxClient

Create user BoxClient using a user access token

UserToken ( string userId ) : string

Once you have created an App User, you can request a User Access Token via the App Auth feature, which will return the OAuth 2.0 access token for the specified App User.

Private Methods

Method Description
ConstructJWTAssertion ( string sub, string boxSubType ) : string
JWTAuthPost ( string assertion ) : OAuthSession

Method Details

AdminClient() public method

Create admin BoxClient using an admin access token
public AdminClient ( string adminToken, string asUser = null, bool suppressNotifications = null ) : BoxClient
adminToken string Admin access token
asUser string The user ID to set as the 'As-User' header parameter; used to make calls in the context of a user using an admin token
suppressNotifications bool Whether or not to suppress both email and webhook notifications. Typically used for administrative API calls. Your application must have “Manage an Enterprise” scope, and the user making the API calls is a co-admin with the correct "Edit settings for your company" permission.
return BoxClient

AdminToken() public method

Get admin token by posting data to auth url
public AdminToken ( ) : string
return string

BoxJWTAuth() public method

Constructor for JWT authentication
public BoxJWTAuth ( IBoxConfig boxConfig ) : Box.V2.Auth
boxConfig IBoxConfig Config contains information about client id, client secret, enterprise id, private key, private key password, public key id
return Box.V2.Auth

Session() public method

Create OAuth session from token
public Session ( string token ) : OAuthSession
token string Access token created by method UserToken, or AdminToken
return Box.V2.Auth.OAuthSession

UserClient() public method

Create user BoxClient using a user access token
public UserClient ( string userToken, string userId ) : BoxClient
userToken string User access token
userId string Id of the user
return BoxClient

UserToken() public method

Once you have created an App User, you can request a User Access Token via the App Auth feature, which will return the OAuth 2.0 access token for the specified App User.
public UserToken ( string userId ) : string
userId string Id of the user
return string