AvdLee / appstoreconnect-swift-sdk

The Swift SDK to work with the App Store Connect API from Apple.
Other
1.48k stars 198 forks source link

JWT Token Expiration #131

Closed Ikloo closed 3 years ago

Ikloo commented 3 years ago

Hi! Thanks for this SDK.

Sometimes AppStoreConnect API return 401 error with this json: { "errors": [{ "status": "401", "code": "NOT_AUTHORIZED", "title": "Authentication credentials are missing or invalid.", "detail": "Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens" }] }

I think it occurred during an API request when the time is close to expiration. decodedBearer.expiryDate.compare(Date()) != ComparisonResult.orderedDescending Maybe change this compare logic and create new token a little earlier? (ex. expiryDate - 5sec)

github-actions[bot] commented 3 years ago

This issue is stale because it has been open for 30 days with no activity. Remove the Stale label or comment or this will be closed in 10 days.