Refresh Token Issue in Node js SDK
回答済みHello Sir,
I have an issue while fetching folder from Box API.By using the below code the code below
var client = sdk.getBasicClient('ACCESS_TOKEN');
It is only working for one hour.After one hour the token is expire. For solving the above issue I am trying to use Curl API for getting request access token.But before I need acces token by follwing code.
curl -X POST https://api.box.com/oauth2/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'client_id=[CLIENT_ID]' \
-d 'client_secret=[CLIENT_SECRET]' \
-d 'code=[CODE]' \
-d 'grant_type=authorization_code'
But here I need to get CODE programtically in node to fetch request acces token. Current If we are hitting url and fetch the code it is expiring in a second.
Please help me as soon as possible. Thank you in advance.
-
Hi , answering your concerns one by one:
1. The access token is only valid for 1 hour from the time of issue,
2. The authorization code should be valid for 30seconds so that you have ample time to do the token call and get a access token and refresh token
3. To avoid step #2, you can store the refresh token and use the same to get a new access token every time the access token expires (do remember with every token call as shown below, current refresh token expires and a new refresh token is responded back by the server for future use) Refer Link for further details
curl -X POST https://api.box.com/oauth2/token \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'client_id=[CLIENT_ID]' \ -d 'client_secret=[CLIENT_SECRET]' \ -d 'refresh_token=[REFRESH_TOKEN]' \ -d 'grant_type=refresh_token'
サインインしてコメントを残してください。
コメント
1件のコメント