Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'error_description': 'Current date/time MUST be before the expiration ' #499

Open
4 tasks done
sasadangelo opened this issue Mar 10, 2025 · 3 comments
Open
4 tasks done
Assignees
Labels
bug Something isn't working

Comments

@sasadangelo
Copy link

sasadangelo commented Mar 10, 2025

Description of the Issue

I run this program and I get:

from box_sdk_gen import BoxClient, BoxJWTAuth, JWTConfig


jwt_config = JWTConfig(
    client_id="49xxxxxq07wp",
    client_secret="02xxxxxxbPxwr",
    jwt_key_id="7cgeazfu",
    private_key="-----BEGIN ENCRYPTED PRIVATE KEY-----\nMIxxxxxxxm4c=\n-----END ENCRYPTED PRIVATE KEY-----\n",
    private_key_passphrase="3abxxxxx2b2cc",
    enterprise_id="4xxxxx",
)
auth = BoxJWTAuth(jwt_config)
client = BoxClient(auth=auth)
access_token = auth.retrieve_token()

Timestamp: 2025-03-10 11:31:45.040844
Underlying error: None
Message: 400 ; Request ID:
Request:
Method: POST
URL: https://api.box.com/oauth2/token
Query params:
{}
Headers:
{ 'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'box-python-generated-sdk-1.9.0',
'X-Box-UA': 'agent=box-python-generated-sdk/1.9.0; env=python/3.9.21'}
Body:
'grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&client_id=xxxxxx&client_secret=xxxxxxx'
Response:
Status code: 400
Headers:
{ 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000',
'Transfer-Encoding': 'chunked',
'cache-control': 'no-store',
'content-type': 'application/json',
'date': 'Mon, 10 Mar 2025 10:31:45 GMT',
'set-cookie': 'box_visitor_id=67cebf90f33cb2.53718461; expires=Tue, 10 '
'Mar 2026 10:31:44 GMT; Max-Age=31536000; path=/; '
'domain=.box.com; secure; SameSite=None, '
'bv=SRCHPLT-2449; expires=Mon, 17 Mar 2025 10:31:44 GMT; '
'Max-Age=604800; path=/; domain=.app.box.com; secure, '
'cn=97; expires=Tue, 10 Mar 2026 10:31:44 GMT; '
'Max-Age=31536000; path=/; domain=.app.box.com; secure, '
'site_preference=desktop; path=/; domain=.box.com; '
'secure',
'strict-transport-security': 'max-age=31536000',
'via': '1.1 google'}
Code: None
Context Info:
{}
Request Id: None
Help Url: None
Body:
{ 'error': 'invalid_grant',
'error_description': 'Current date/time MUST be before the expiration '
"date/time listed in the 'exp' claim"}
Raw body: {"error":"invalid_grant","error_description":"Current date/time MUST be before the expiration date/time listed in the 'exp' claim"}

The problem is reported only on Mac when I run it on my office network. The point is that I contacted team but they want to know what could be the potential issues on the server side to do a correct diagnoses on their servers.

Steps to Reproduce

See above

Expected Behavior

It can get the bearer token

Error Message, Including Stack Trace

See boave

Screenshots

n/A

Versions Used

Python SDK: 1.9.0 and 1.12.0
Python: 3.9

@mwwoda
Copy link
Contributor

mwwoda commented Mar 10, 2025

That usually indicate that clock on your machine is out of sync with clock on Box servers. You could compare it to https://www.unixtimestamp.com/

@sasadangelo
Copy link
Author

Hi, thank you for your reply. I have read this in several docs and forum. I did it and the time is ok. In fact, the problem only occurs in my office network and only from Mac.

@mwwoda
Copy link
Contributor

mwwoda commented Mar 11, 2025

I would still suggest to troubleshoot it on your side, if you see issues in this specific environment. This problem comes from the API, and indicates problem with exp claim. I still don't see connection with it and this SDK. We also didn't observe it in any other environment.

You could also try to reach out Box forums - https://community.box.com/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants