Hey everyone,
I’m trying to set up a CI/CD pipeline using GitHub Actions to update our WEM routing strategies via the REST API. The issue is that the standard access tokens expire way too quickly for the way our pipeline is structured, and I keep getting 401 Unauthorized errors halfway through the run.
I read that I should use an app token for this, but the documentation is a bit vague on how to generate one that actually works for automation without manual intervention every time.
Here is the snippet I’m currently using in the workflow to get the token:
TOKEN_RESPONSE=$(curl -X POST \
'https://{{my_subdomain}}.mygen.com/oauth/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials&client_id={{my_client_id}}&client_secret={{my_client_secret}}')
ACCESS_TOKEN=$(echo $TOKEN_RESPONSE | jq -r '.access_token')
The token comes back fine, but it only lasts for an hour. Our pipeline takes longer than that because it iterates through multiple flow updates. I tried setting the expires_in parameter, but the API ignores it and gives me the default duration.
Is there a specific endpoint or header I need to use to get a long-lived token? Or am I supposed to be using a different grant type entirely for this use case? I don’t want to have to implement a token refresh loop in the shell script if I can just get a token that lasts longer.
Thanks for the help.