https request is not executing using CURL

新規投稿

コメント

4件のコメント

  • Murtza

    I am not sure why you are seeing this error. 

     

    Have you seen this StackOverflow post it might provide some direction on the possible cause?

    0
    コメントアクション パーマリンク
  • lguo

    I follow the instruction of https://docs.box.com/docs/oauth-20 and get an authorization code, then I 

    curl https://www.box.com/api/oauth2/token -d 'grant_type=authorization_code&code={your_code}&client_id={your_client_id}&client_secret={your_client_secret}' -X POST

     

    I almost always get this below same error after many tries with different authorization codes

    curl: (56) SSL read: error:00000000:lib(0):func(0):reason(0), errno 10054

     

    Very occasionally I get below expiration error, I am sure it is within 30 seconds, if I keep running same curl command and it will go back the above same errno 10054, this probably happens after 30 seconds, when authorization code is truely expired. Instead of giving me below expiration error, it goes back and always gives me errno 10054

    {"error":"invalid_grant","error_description":"The authorization code has expired"}

     

    If I change into a wrong authorization code, I do see the below correct invalid error several times, but it will go back and return to errno 10054 most times.

    {"error":"invalid_grant","error_description":"Auth code doesn't exist or is invalid for the client"}

     

    Lastly, after hundreds of tries in the past several days, the magic happens and I get the correct token response. 

    {"access_token":"9McgXm7hu3WgNPcAx5ilx0lmHZHlyuY5","expires_in":3698,"restricted_to":[],"refresh_token":"1eeQkGwFonnN5i3x0KiNy3RtLD7d5WHyOeJ3tKomyyqCz8488dbInlu3vyJlcgXP","token_type":"bearer"}

     

    It leads to me think it might not be something wrong on my side. I tried different computers and different networks on my 2 box accounts, the other box dev account has not any luck so far. Does anyone encounter the same problem? I would be highly appreciated that any Box Product Developer can check and test the oauth2 token generations.

     

    0
    コメントアクション パーマリンク
  • lguo

    Anyone can report or help check if you can get a pair of access_token and refresh_token, and the subsequent pair of  access_token and refresh_token every time consistently from the Box OAuth2 https://docs.box.com/docs/oauth-20#section-5-getting-the-access-token ?

     

    I have a very hard time to get a successful token with many different authorization codes for the past several days, it almost always returns below errno 10054, [Errno 10054] An existing connection was forcibly closed by the remote host

    curl: (56) SSL read: error:00000000:lib(0):func(0):reason(0), errno 10054

     

    But I do have 2 successful returns so far as below, it works for an hour as it is supposed. Also I have no luck to use the Refresh Token to generate a new Access and Refresh Token after many tries, it returns the same errno 10054.

    {"access_token":"ad3WR4ii1xV3BLEuBACH5ET8rQaNsChU","expires_in":3944,"restricted_to":[],"refresh_token":"rniHQFJ2gqpfWMRSnFPSqVZuzclq71YwSE3anj3RjLVJV0JYpGv3khQrjEwOE9le","token_type":"bearer"}

     

    I very appreciate of any reply to help me narrow down the problem of errno 10054

    0
    コメントアクション パーマリンク
  • lguo

    The curl command seems to be working fine now. Actually all you need is just one success with https://docs.box.com/docs/oauth-20#section-5-getting-the-access-token .  If you have one success with access_token and refresh_token, you are good and you have 60 days before the expiration of refresh_token. You do not need not do it again unless you don't save it or the subsequent pair of access_token and refresh_token for regenerating the token.

     

    For the next step https://docs.box.com/docs/oauth-20#section-6-using-the-access-and-refresh-tokens , normally you do not do it in curl command. For my case, I am using below Box Java SDK 

    BoxAPIConnection api = new BoxAPIConnection("YOUR-CLIENT-ID",
    "YOUR-CLIENT-SECRET", "YOUR-ACCESS-TOKEN", "YOUR-REFRESH-TOKEN");
    api.refresh(); 

    The api.refresh() is very reliable to get a new set of access_token and refresh_token everytime, you just need to save the current token to somewhere like text file for regenerating the next token. 

     

    The OAuth2 is working for me as it is expected and I am happy with it now, no further assistance is needed. 

    0
    コメントアクション パーマリンク

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