Hello,
I’m trying to get the offline impersonation to work properly. (https://developer.atlassian.com/platform/forge/remote/calling-product-apis/#offline-user-impersonation) I’m able to get a valid impersonated token from the GraphQL API but when I use it to create a worklog on a valid Jira issue is get the following error:
{‘errorMessages’: [‘Issue does not exist or you do not have permission to see it.’], ‘errors’: {}}
Forge manifest info on permissons:
permissions:
scopes:
read:app-system-token: {}
read:jira-work:
allowImpersonation: true
write:jira-work:
allowImpersonation: true
I then use invokeRemote to call the backend:
I decode the FIT and I grab the cloudId: https://developer.atlassian.com/platform/forge/remote/essentials/#the-forge-invocation-token--fit-
The system token is coming from the x-forge-oauth-system
header.
The app is installed on the development space, I’m trying to impersonate myself as a test as the only contributor of the app.
context_id = f"ari:cloud:jira::site/{decoded_fit['context']['cloudId']}"
url = "https://api.atlassian.com/graphql"
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": f"Bearer {system_token}"
}
query = """
mutation forge_remote_offlineUserAuthToken($input: OfflineUserAuthTokenInput!) {
offlineUserAuthToken(input: $input) {
success
errors {
message
}
authToken {
token
ttl
}
}
}
"""
payload = {
"query": query,
"variables": {
"input": {
"contextIds": [context_id],
"userId": user_account_id
}
}
}
response = requests.post(url, headers=headers, json=payload)
I then try to create a worklog using the provided token directly as bearer token:
worklog_data = {
"comment": comment,
"timeSpentSeconds": time_spent_seconds,
"started": started
}
headers = {
"Authorization": f"Bearer {access_token_from_graphql}",
"Content-Type": "application/json",
}
return requests.post(
f"{BASE_URL}/rest/api/latest/issue/{jira_issue_key}/worklog",
headers=headers,
data=json.dumps(worklog_data),
)
That endpoint gives me:
{‘errorMessages’: [‘Issue does not exist or you do not have permission to see it.’], ‘errors’: {}}
Any ideas what I’m doing wrong here?
Thanks!