Error: Grant credentials are invalid 2022

New post



  • Alex Novotny


    Couple of follow up questions for you. 

    May I see the code you are running? 

    Have you tried it with the enterprise keyword and enterprise id? 

    Alex, Box Developer Advocate

    Comment actions Permalink
  • Albert Chen

    Hello Alex,

    I am trying to upload files via API, and enterprise id doesn't work for that.

    Although, I am able to successfully generate an access token with enterprise id, I get this error when running my upload code:

    {"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"parent","message":"Invalid value 'd_155054681560'. 'parent' with value 'd_155054681560' not found"}]},"help_url":"http:\/\/\/docs\/#errors","message":"Not Found","request_id":"hbgddxh0allyle98"}

    This is the code I am using.


    That is why I am trying to use user and user id in box_subject_id and box_subject_type, but I am getting this error.




    Comment actions Permalink
  • Artur Jankowski
    Hello  Albert Chen

    I see that in your example you created a connection with directly passed access token instead of using one of these constructor:

    BoxCCGAPIConnection api = BoxCCGAPIConnection.applicationServiceAccountConnection(
    BoxCCGAPIConnection api = BoxCCGAPIConnection.userConnection(

    Please visit this documentation page for more details about how to use CCG

    User connection
    The reason why user BoxCCGAPIConnection.userConnection() is not working for you is probably due to missing your app's authorization by an admin.
    Please go to your app in Then go to "Authorization" tab at the top and click "Review and Submit". After that your admin should accept this changes.

    Account Service connection

    The reason why you cannot upload a file using enterprise connection is that account service is separate from the Box accounts of the application developer and the enterprise admin of any enterprise that has authorized the app — files stored in that account are not accessible in any other account by default, and vice versa.

    So after you created an BoxCCGAPIConnection.applicationServiceAccountConnection() connection
    you should use `asUser()` function described here to make API calls on behalf of managed user which has access to this folder `155054681560`. But in order to do this you should firstly turn on "Make API calls using the as-user header" on your app on "Configuration" tab and "Advanced Features" section. Then you should go to "Authorization" tab at the top and click "Review and Submit". After that your admin should accept this changes.

    Please let me know if it helped you.


    Comment actions Permalink
  • Albert Chen

    Thank you Artur Jankowski,

    The issue has been resolved.

    Comment actions Permalink

Please sign in to leave a comment.