Upload File API error: no "files" permission

Hi,

I’m trying to upload a file via /files/v3/files API method and I’m getting error

{"status":"error","message":"This app hasn't been granted all required scopes to make this call. Read more about required scopes here: https://developers.hubspot.com/scopes.","correlationId":"54643f16-bbc5-4af1-9571-a93911eee531","errors":[{"message":"All of the following scopes are required.","context":{"requiredScopes":["files"]}}],"links":{"scopes":"https://developers.hubspot.com/scopes"},"category":"MISSING_SCOPES"}

I doublechecked that my API token has needed “files” scope via another API method https://api.hubapi.com/oauth/v1/access-tokens/:accessToken

{
 ...
 "scopes": [
 "content",
 "automation",
 "oauth",
 "forms",
 "files",
 "tickets",
 "e-commerce",
 "crm.lists.read",
 "crm.objects.contacts.read",
 "crm.objects.contacts.write",
 "files.ui_hidden.read",
 "crm.objects.companies.write",
 "crm.schemas.contacts.read",
 "crm.lists.write",
 "crm.objects.companies.read",
 "crm.objects.deals.read",
 "crm.objects.deals.write",
 "crm.schemas.companies.read",
 "crm.schemas.companies.write",
 "crm.schemas.contacts.write",
 "crm.schemas.deals.read",
 "crm.schemas.deals.write",
 "crm.objects.owners.read"
 ],
 ...
}

During oAuth request I’m requesting “files” (within several other scopes) scope as required scope.

Hey @PJMuller

That error is related to how your developer app is set up. When you navigate to your developer app and then go to the Auth tab, I suspect your app is missing the files scope. If you have recently added files functionality into your app, I would re-authenticate the app with your HubSpot portal.

Hope that helps!

Hi, @tominal
Thank you for your reply.

How should I re-authenticate the app with HubSpot portal? After adding new scope to app config, I just follow the regular oAuth flow with a user account and obtain a new access token. Do I need to do anything special right after adding new scope to the app config?

That sounds right to me! If you’re still experiencing issues after that, I would uninstall the developer app from the HubSpot portal and re-authorize it.