Welcome to the new Box Support website. Check out all the details here on what’s changed.

Looking for Python SDK Webhook (v2) Sample Code or Tutorial

New post

Comments

3 comments

  • j12y

    From another thread, it looks like I'm running into a similar issue:

     

     wrote:

    when you use JWT you don't authenticate as you, the managed user. Instead you are authenticate as a service account, which obviously does not have access to your files and folders.

     

    You can use the as-user header to access your own files and folders.

     

    https://developer.box.com/guides/authentication/jwt/as-user/


    I was confused by this as well.  Is the as-user header the only approach?  If Application Scopes include "Read and write all files and folders stored in Box" how can it query as the service account to find files / folders across the entire instance?

    0
    Comment actions Permalink
  • j12y

    I did figure out how to get user id for a specific user as mentioned in my problem description but that approach gets a 403 "The request requires higher privileges than provided by the access token."

     

     

     

        def get_user_id(self, login):
            """
            Looks up the user_id for a given user's login.  This
            can often be found in the user's account and can
            be useful for other methods that require a user_id as
            input.
            """
            users = self.client.users(filter_term=login)
            for user in users:
                if login == user.login:
                    return user.id
    
            logging.warn("User with login {} not found".format(login))
    
    user_id = self.get_user_id('***email address removed for privacy***')
    user = self.client.user(user_id=user_id)
    user_client = self.client.as_user(user)
    results = user_client.search().query('foo')
    print(results)
    # FAILS: 403

     

     

    I should note, I do have "Perform Actions as Users" enabled for this custom app.

     

    0
    Comment actions Permalink
  • j12y

    I've found a workaround by sharing the folder with the ***email address removed for privacy*** which allows the custom app to read files in that folder hierarchy.  Is that the only way to search for files across an enterprise?

     

    I'm also trying to chase down the enterprise_scope variable to the search() function, not sure how to enable that and my ticket to support hasn't been looked at yet.

    0
    Comment actions Permalink

Please sign in to leave a comment.