Content API Question: File ID is available but Cannot Download it. Return 404 Error

回答済み
新規投稿

コメント

8件のコメント

  • Box Product Support

    I got same error i want to get content from file

    0
    コメントアクション Permalink
  • kendomen

    what if you add:

    -H "As-User: "

    0
    コメントアクション Permalink
  • pengyin_shan

    Hi I have this problem solved. The reason of this problem is in my old way, I messed up with Enterpise Token and App User Token. I created a temporary user every time I tried to get authentication using enterprise token. These users (after I check my user list, a lot...) did not have access to my file, which resulting in 404 error.

     

    My correct way of getting through authetication:

    1. Generate JWT using my Enterprise ID

    2. Use this JWT to send a post request to Box API 'https://api.box.com/oauth2/token' to get Enterprise Access Token 

    3. Use https://api.box.com/2.0/users -H "Authorization: Bearer EnterprisAccessToken" to get user_id 

    4.Generate JWT using my user_id

    5. Use new JWT to get User Access Token

    6. Use User Access Token to download my file

     

    For any one who may have same problem as me, https://docs.box.com/docs/app-users provide a good explaination about the difference between enterprise token and user access token.

     

    And thank you for your help!

     

     

    0
    コメントアクション Permalink
  • SnwlCasInfo

    could you please give me one help, I don't how to generate JWT using user id, thanks very much.

    0
    コメントアクション Permalink
  • pengyin_shan

    I'm not sure what programming language you use, but I remember I used a JavaScript JWT token library. This link has all libraries you can use https://jwt.io/#libraries-io.

    0
    コメントアクション Permalink
  • SnwlCasInfo

    I am using python as below to generate the enterprise token, but I don't know how to generate the user access token using user id

    auth = JWTAuth(
    client_id=CLIENT_ID,
    client_secret=CLIENT_SECRET,
    enterprise_id=ENTERPRISE_ID,
    jwt_key_id=JWT_KEY_ID,
    rsa_private_key_file_sys_path=PRIVATE_KEY_FILE,
    )
    print("enterprise access token: ", auth.authenticate_instance())
    0
    コメントアクション Permalink
  • pengyin_shan

    I forgot most of the details, but probably change the enterprise_id attribute to something like user_id may work?

    0
    コメントアクション Permalink
  • SnwlCasInfo

    there is no parameter of user_id for JWTAuth

    0
    コメントアクション Permalink

サインインしてコメントを残してください。