Skip to content

Can't deserialize FileOrFolderScopeScopeField #250

Closed
@namack

Description

@namack

Description of the Issue

Downscoping of a token with the scope item_upload causes serialization issues.

Downscoping a token using the base_explorer scope on a resource works as intended:

const token = await client.auth.downscopeToken(
    ['base_explorer'],
    `https://api.box.com/2.0/folders/${folderId}`,
  );

However, once the item_upload scope is added a deserialization error is thrown:

const token = await client.auth.downscopeToken(
    ['base_explorer', 'item_upload'],
    `https://api.box.com/2.0/folders/${folderId}`,
  );

Error:

BoxSDKError: {
  "message": "Can't deserialize FileOrFolderScopeScopeField"
}

I believe this scope is missing in the deserializeFileOrFolderScopeScopeField function.

export function deserializeFileOrFolderScopeScopeField(

Steps to Reproduce

Call the downscopeToken function with item_upload included in the scope:

const token = await client.auth.downscopeToken(
    ['base_explorer', 'item_upload'],
    `https://api.box.com/2.0/folders/${folderId}`,
  );

Expected Behavior

I expect a valid token to be returned to allow the App User to upload files and create folders.

Error Message, Including Stack Trace

{
  "message": "Can't deserialize FileOrFolderScopeScopeField"
}
at deserializeFileOrFolderScopeScopeField (/app/node_modules/box-typescript-sdk-gen/src/schemas/fileOrFolderScope.generated.ts:73:9)
at y8u (/app/node_modules/box-typescript-sdk-gen/src/schemas/fileOrFolderScope.generated.ts:100:9)
at <anonymous> (/app/node_modules/box-typescript-sdk-gen/src/schemas/accessToken.generated.ts:110:18)
at Array.map (<anonymous>)
at x8u (/app/node_modules/box-typescript-sdk-gen/src/schemas/accessToken.generated.ts:107:28)
at jvr.<anonymous> (/app/node_modules/box-typescript-sdk-gen/src/managers/authorization.generated.ts:294:12)
at Generator.next (<anonymous>)
at a (/app/node_modules/box-typescript-sdk-gen/src/networking/fetch.ts:380:1)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Screenshots

Not applicable

Versions Used

Typescript SDK: 1.2.0
Platform: Node
Node.js (if applicable): v20.11.0

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions