Skip to main content
Question

Having trouble setting up and instanciating a service account

  • March 6, 2025
  • 1 reply
  • 7 views

I have set up an application. 
I have specified the authentication method as OAuth 2.0 with JSON Web Tokens (Server Authentication) 
I have specified the app access level to App + Enterprise Access
I have valid oauth2 credentials. 
I have the following application scopes enabled.

  • 1- Read all files and folders store in Box Access to content is further restricted by the user' permission and Access Token used
  • 2- Write all files and folders store in Box Necessary to download files and folders.  Access to content is further restricted by the users' permission and Access Token used.  Read access is required when Write access is selected. 
  • 4- Manage Users
  • 5- Manage Groups
  • 6- Manage retention policies for use with the governance add-on7- Manage enterprise properties for use with the event stream, enterprise's attributes, and device pins.  App + Enterprise Access is required to use this scope. 
  • Manage enterprise properties for use with the event stream, enterprise's attributes, and device pins.  App + Enterprise Access is required to use this scope.
  •  

I have set Advanced Features of Generate user access tokens
I have added a public key
I have downloaded and correctly setup a config.json.  
I am using the JWT auth code that was specified in the documentation. 
 

    auth = JWTAuth.from_settings_file('config.json')
    client = Client(auth)
    service_account = client.user(user_id='me').get()
    return service_account

I am still getting the following error: 

 

auth = JWTAuth.from_settings_file('config.json')client = Client(auth)service_account = client.user(user_id='me').get()print(f'Service Account user ID is {service_account.id}')return service_account

Also, I invited the service account to collaborate on my files.  

Please help me sort out this error. 

Thanks in advance

Lois


​​​​​​​

1 reply

  • Author
  • New Participant
  • 1 reply
  • March 7, 2025

Sorry, I didn’t post the error correctly. Below is the correct error that I’m receiving. 

 

   raise self._oauth_exception(box_api_exception.network_response, url) from box_api_exception
boxsdk.exception.BoxOAuthException: 
Message: This app is not authorized by the enterprise admin
Status: 400
URL: https://api.box.com/oauth2/token
Method: POST
Headers: {'date': 'Thu, 06 Mar 2025 21:14:15 GMT', 'content-type': 'application/json', 'strict-transport-security': 'max-age=31536000', 'set-cookie': 'box_visitor_id=67ca1027554551.35569392; expires=Fri, 06 Mar 2026 21:14:15 GMT; Max-Age=31536000; path=/; domain=.box.com; secure; SameSite=None, bv=EI-10463; expires=Thu, 13 Mar 2025 20:14:15 GMT; Max-Age=601200; path=/; domain=.app.box.com; secure, cn=12; expires=Fri, 06 Mar 2026 21:14:15 GMT; Max-Age=31536000; path=/; domain=.app.box.com; secure, site_preference=desktop; path=/; domain=.box.com; secure', 'cache-control': 'no-store', 'via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000', 'Transfer-Encoding': 'chunked'}

Process finished with exit code 1
 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings