I'm building an application that uses the Jira REST API. The application has its own service account with its own jira login separate from any individual account.
As a one-off setup step, I have logged into Jira as the service account, and generated an API token from this page:
Initially everything worked fine. However over time the application started getting 401 errors on some requests, especially when trying to access recently created issues, epics, and sprints. Once I go and log back into Jira manually as the service account, the application seems to start working again.
My current theory is that API keys can only access entities (issues, epics, sprints, etc) that existed at the time of the last login on the account that owns the API key. So for a service account that no one ever logs into, it gradually loses access to the most recent data.
Is my theory correct? And is there a way around it if so? I don't want to have to log in as the service account every now and then to "refresh" its access.
I don't think your theory is correct. Assuming that you can access the problem entities via the UI and you're definitely using the same account in both API and login, my best guess is that a Jira/Cloud admin is changing something. Are you are admin yourself? If not, ask one of the admins if here are any scripts or automation running around user management.
Other thoughts:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.