Difference Between renew() and credentials() API in Swift SDK for minTTL Support

Problem statement

In Auth0 Swift SDK, the credentials() API supports the minTTL parameter to retrieve a new access token before the access token expires. Why is this missing for renew() API?

Solution

As also discussed in this GitHub issue, the renew() API is for renewing the token every time the request is made, even if the token has not expired. Notice a parameter named forceRenewal: true is passed to the private function with the renew() API. This parameter forces token renewal immediately, so having TTL will not change the outcome.

On the other hand, the credentials() API is for retrieving the token from the storage if it has not expired, so minTTL would be helpful when the application has to renew the access token before it has expired.