问题
When using the WSO2 AM via the Store it is possible to set a Validity Time, so that the access token expire time can be increased/decreased.
Is it possible to set the Validity Time via cURL when generating a new token?
E.g. Normal token generation command:
curl -k -d "grant_type=client_credentials" -H "Authorization: Basic userToken, Content-Type: application/x-www-form-urlencoded" localhost:8243/token
{"scope":"am_application_scope default","token_type":"bearer","expires_in":1367,"access_token":"1234456677890"}
Possible token generation command with setting validity time:
curl -k -d "grant_type=client_credentials" -d "validity_time=99999" -H "Authorization: Basic userToken, Content-Type: application/x-www-form-urlencoded" localhost:8243/token
{"scope":"am_application_scope default","token_type":"bearer","expires_in":99999,"access_token":"1234456677890"}
What is the correct command to use for setting this? The reason for this, is because I would like the users of the API Manager be able to set the expire date via a Java API client that we offer.
回答1:
This is not supported out of the box. You can implement it by writing a custom OAuth Grant Type. Please refer [1] for more details on how to write a custom OAuth Grant Type.
[1] https://docs.wso2.com/display/IS500/Writing+a+Custom+OAuth+2.0+Grant+Type
来源:https://stackoverflow.com/questions/31653771/wso2-api-manager-1-9-0-set-expire-date-validity-time-via-curl