[Solved] How to solve oauth2: cannot fetch token issue when configuring Jira Mattermost plugin

I am currently facing an error that prevents me from finishing my Mattermost Jira plugin configuration.

Steps to reproduce
Run /jira instance install cloud mattermost.server.url
Run the steps mentioned and upload the app to Jira
Run /jira connect and get redirected to page with error

Expected behavior
/jira connect command works and Mattermost can successfully connect to Jira plugin

Observed behavior
Error after being redirect to Jira

could not get user info for client, err: No response returned: Get "https://server.atlassian.net/rest/api/2/myself": oauth2: cannot fetch token: 400 Bad Request
Response: {"error":"invalid_grant","error_description":"Invalid aud: https://auth.atlassian.io"}

We are also having this issue. Does anyone know the fix for this?

1 Like

Welcome both of you to the Mattermost Community Forums, and I’m sorry to hear about the issues you’re experiencing.

It seems that you’re encountering an error while configuring your Mattermost Jira plugin. The error message indicates that there was an issue fetching user information from the Jira server, resulting in a 400 Bad Request error with the response stating “invalid_grant” and “Invalid aud: https://auth.atlassian.io”.

This error typically occurs when there is a misconfiguration in the Jira server or the Jira app link. To troubleshoot this issue, I recommend the following steps:

  1. Verify the Jira server URL: Ensure that the mattermost.server.url parameter you provided is correct and matches the URL of your Mattermost server.
  2. Check the Jira app configuration: Review the configuration settings for the Jira app and ensure that the redirect URLs are correctly specified. Make sure that the redirect URL matches the URL where your Mattermost server is accessible.
  3. Validate Jira app credentials: Verify that the Jira app credentials (client ID and secret) are correctly set up in Mattermost and match the credentials provided in Jira. Double-check that you have entered them accurately without any typos.
  4. Ensure proper network connectivity: Confirm that your Mattermost server is accessible from the Jira server without any network restrictions or firewalls blocking the connection.

If you’ve gone through these steps and the issue persists, it may be helpful to provide more details about your configuration and any additional error messages you receive. This will enable us to provide more specific guidance to resolve the problem.

Best regards,
~Matterbot 1.0

[Disclaimer: This is a new automated response feature we’re testing powered by ChatGPT. Please be aware that this response should be considered as a simulated suggestion and may not always reflect official Mattermost recommendations or support. Use the information provided at your own discretion. Were any of the above suggestions inaccurate? Please feel free to reply with any suggested corrections!]

We are a paid customer and facing the exact same problem. Can probably someone give some advice that are more usefull than chatgpt?

Hello Patrick,
If you are on a paid plan, you should head to https://support.mattermost.com/ where you can create a ticket and receive human based support

thanks, I already did and waiting for investigation.

1 Like

We ran into this and struggled for a bit. Final solution was:

  • Update to latest Jira plugin inside Mattermost
  • Make sure Jira instance is uninstalled in Mattermost /jira instance uninstall <INSTANCE>
    One note that we could not easily remove our Jira instance from Mattermost so we had to manually nuke all the Jira plugin settings by running a database command.
DELETE FROM pluginkeyvaluestore WHERE pluginid='jira';
  • Delete Mattermost plugin on Jira side if it exists
  • From Mattermost re-run the setup and go through process of regenerating a new token and installing the Mattermost plugin within Jira /jira setup

Hope this helps somebody.

1 Like

You rock, Lmorroni! :tada: