Get Access Token using RefreshToken
-
The refresh token changes every time you refresh, and you can't use the same refresh token twice. When you make the API call to refresh, the API send back both a new access token and a new refresh token. You'll need to store the new refresh token when you refresh the first time, and use the new refresh token when you want to refresh a second time.
-
, it sounds like your redirect URL is set to your root folder / home page on Box (e.g. app.box.com). You'll want to change your app's redirect URL to a URL that you control instead, because after the user logs in, Box will redirect the user to your redirect URL and then append the authorization code to the URL.
At that point, your app would then take the authorization code and exchange it for an access token.
To change your redirect url:
- Go to your Developer Console (app.box.com/developers/console)
- Select your app
- Select Configuration on the left hand sidebar
- Find the "OAuth 2.0 Redirect URI" Section
- change the redirect url to the URL for your app (e.g. myapp.heroku.com/oauth2)
You can see more about it in our docs:
https://developer.box.com/docs/authenticate-with-oauth-2
Hope that helps!
-
i tried below method for Authentication.
https://developer.box.com/docs/authenticate-with-jwt
Once the client is created and i tried to get a folder info it throws Following Error.
"GET https://api.box.com/2.0/folders/7984021****/items?offset=0" 404 322 {'Content-Type': 'application/json', 'Content-Encoding': 'gzip', 'Date': 'Wed, 26 Jun 2019 12:28:15 GMT', 'BOX-REQUEST-ID': '1u9ukebuecgsfkjqgr37ghe2b5l', 'Cache-Control': 'no-cache, no-store', 'Strict-Transport-Security': 'max-age=31536000', 'Transfer-Encoding': 'chunked', 'Vary': 'Accept-Encoding', 'Connection': 'keep-alive'} {'code': '---ound', 'context_info': {'errors': [{'message': "Invalid value 'd_7984021****'. " "'folder' with value 'd_7984021****' " 'not found', 'name': 'folder', 'reason': 'invalid_parameter'}]}, 'help_url': 'http://developers.box.com/docs/#errors', 'message': 'Not Found', 'request_id': '19xhakg4etyd80q8', 'status': 404, 'type': 'error'}
But if i create a client from manually generated Developer Token from console. I can get the same folder Info. -
Developer tokens are associated with the account that's logged into the developer console when the token is generated. Therefore, you'll only be able to interact with folders/files that account owns or has collaborator access to. A 404 indicates that the token you're making this call with does not have access to the folder you're trying to get.
Best,
Kourtney
-
This is how i am making request. Correct me if i am doing anything wrong. Already authorized app from Admin Console.
from boxsdk import OAuth2, Client
from boxsdk import JWTAuthsdk = JWTAuth.from_settings_file('./box_config.json')
ac_token = sdk.authenticate_instance(enterprise='21073****')auth = OAuth2(
client_id=,
client_secret=,
access_token=ac_token
)
client = Client(auth)
folder=client.folder(folder_id='798402*****').get_items()Tried this also but didn't work:
sdk = JWTAuth.from_settings_file('./box_config.json')
client = Client(sdk)
folder=client.folder(folder_id='798402*****').get_items() -
You're getting a token and making calls for your JWT application's service account. Taking a look on the backend, this user doesn't own or collaborate on any content. You need to add this user as a collaborator on the folder you're trying to access, 798402*****.
サインインしてコメントを残してください。
コメント
11件のコメント