I have a new Box account. I created a new Box app from the developer console to process files stored in Box using a Python script. But the app_user_auth.authenticate_user() step is failing with below error
**BoxOAuthException**: Message: Please check the 'sub' claim. The 'sub' specified is invalid.
Status: 400
URL: https://api.box.com/oauth2/token
Method: POST
My python code looks like below
from boxsdk import JWTAuth, Client
import json
with open('./settings_config.json','r') as file:
config_json = json.load(file)
auth = JWTAuth.from_settings_dictionary(config_json)
service_account_client = Client(auth)
app_user = service_account_client.user(user_id='xxxx')
app_user_auth = JWTAuth(
client_id=config_json['boxAppSettings']['clientID'],
client_secret=config_json['boxAppSettings']['clientSecret'],
user=app_user,
jwt_key_id=config_json['boxAppSettings']['appAuth']['publicKeyID'],
rsa_private_key_data= config_json['boxAppSettings']['appAuth']['privateKey'],
rsa_private_key_passphrase=config_json['boxAppSettings']['appAuth']['passphrase'],
enterprise_id=config_json["enterpriseID"]
)
app_user_auth.authenticate_user()
app_user_client = Client(app_user_auth)
and my settings_config json file looks like this
{
"boxAppSettings": {
"clientID": "xxxxxxxxx",
"clientSecret": "xxxxxxxxx",
"appAuth": {
"publicKeyID": "xxxxxxx",
"privateKey": "-----BEGIN ENCRYPTED PRIVATE KEY----- xxxxxxxxx",
"passphrase": "xxxxxx"
}
},
"enterpriseID": "xxxxx"
}
Please help me with a resolution. I have a valid enterprise ID here as I am using my employer’s account.