Error message : Repository access token no longer valid
Asked by shallu_bassi_capgemini_com:

I receive an error message in Postman,

Your repository's access token is no longer valid. Please disconnect and then reconnect to continue working on your repository in Postman.

Action: Disconnect Repository and connect again

Set up:

1. Created an API in postman and added collection to it

2. Connected the API to Remote repository in Bitbucket

3. Every next day the repository action token becomes invalid and have to disconnect and connect again.

How to solve this?

Thanks in advance


Answers:
author: Patrik S
body: Hello [@shallu_bassi_capgemini_com](/t5/user/viewprofilepage/user-id/5133230) ,

Welcome to Atlassian Community!

In case you are using Bearer access tokens in Postman, they do have an expiration of two hours, at which point you will need to renew them using the refresh token, or configure postman to do it automatically for you.

Could you please confirm which authentication type you have configured in Postman (OAuth, Bearer, Basic, etc...) and how you are getting the new access token once it fails ?

Thank you, [@shallu_bassi_capgemini_com](/t5/user/viewprofilepage/user-id/5133230) !

Patrik S

comments: author: shallu_bassi_capgemini_com
body: Hi Pratik,

Thank you for writing back.

My target is to connect a collection in API with remote repository

1. I am using demo requests in the Collection

2. I generate the access token in one of the requests

3. Save the access token in a variable {{AccessToken}}

4. In Authorization , select Bearer token and feed the above variable.

Secondly, my collection works without Authorization as well :)

5. I have connected the API in Postman to a Bitbucket Repository and set up a pipeline there

6. The pipeline is set up for a schedule run - daily nightly runs

**My problem is , the connection to remote repository in bitbucket from Postman gets disconnected.**

**then I get a message in my Postman that I need to disconnect to the remote Repo and connect again**

**Attached screenshot as well for your reference. :)**

Its not happening everyday, but some days.

Because I checked that the pipeline is getting executed from past 3-4 days without my intervention.

I hope my explanation is helpful.


author: Patrik S
body: Hey [@shallu_bassi_capgemini_com](/t5/user/viewprofilepage/user-id/5133230) ,

Could you please share a screenshot of where exactly in postman you are connecting to the remote repository in Bitbucket?

Is the end goal of your integration to have your Postman API collections pushed to a bitbucket repository as defined in [Postman - Integration Bitbucket](https://learning.postman.com/docs/integrations/available-integrations/bitbucket/) ?

Also, would it be possible for you to share any Postman documentation related to the integration you are trying to use? This will help us to better understand how Postman is handling the authentication with Bitbucket.

Thank you, [@shallu_bassi_capgemini_com](/t5/user/viewprofilepage/user-id/5133230)

Patrik S


author: shallu_bassi_capgemini_com
body: Hi Pratik,

Just to let you know, I am doing a POC for a potential client.

1. Integrate Postman -\> Jira and execute collections in nightly pipelines

2. View the result of pipeline execution in the Jira dashboard

So, I have to present case study

Postman API -\> Bitbucket repo -\> Bitbucket pipeline -\> Integrate with Jira and show the result on Jira dashboard.

Postman API -\> Bitbucket repo -\> Jenkins pipeline -\> Integrate with Jira and show the result on Jira dashboard.

So, I would like to solve the issue as soon as possible , since my findings would effect the selection of Tool at my client.

I will answer step by step from your reply

Please note, I have a repo created in Bitbucket before connecting the Postman API

Q1. Could you please share a screenshot of where exactly in postman you are connecting to the remote repository in Bitbucket?

Attached Screenshot![Postman API connect to Remote Repo.png](https://community.atlassian.com/t5/image/serverpage/image-id/239494i5BDC5EEB97AB1C8F/image-size/large?v=v2&px=999 "Postman API connect to Remote Repo.png")

Q2. Is the end goal of your integration to have your Postman API collections pushed to a bitbucket repository as defined in [Postman - Integration Bitbucket](https://learning.postman.com/docs/integrations/available-integrations/bitbucket/) ?

Yes, its first part of my goal

Finally, I want to execute a pipeline in Bitbucket and run the postman collection(API) in the pipeline.

So far,

1. I have connected the Postman - API to bitbucket repository

2. and further to a bitbucket pipeline , using Postman CLI configuration;

screenshots attached

2.1 I have added the API key from Postman to the Bitbucket as a parameter

![Postman CLI configuration part 1 for postman.png](https://community.atlassian.com/t5/image/serverpage/image-id/239496iD5AD431BA86FFFF1/image-size/large?v=v2&px=999 "Postman CLI configuration part 1 for postman.png")![Postman CLI configuration part 2 for postman.png](https://community.atlassian.com/t5/image/serverpage/image-id/239495iC952CEBC17AECDED/image-size/large?v=v2&px=999 "Postman CLI configuration part 2 for postman.png")

\<Removed image due to privacy\>

So far, my API -collections run well in the pipeline,

Q3. Also, would it be possible for you to share any Postman documentation related to the integration you are trying to use?

The link used to connect Postman to the Bitbucket Pipelines

<https://learning.postman.com/docs/integrations/available-integrations/ci-integrations/bitbucket-pipelines/#configuring-the-postman-cli-for-bitbucket-pipelines>

Problems

1. S**ometimes I get the error message that Remote repo connection is invalid and disconnect the repo**

**So, I disconnect and connect again**

2. Secondly , I dont use any Authorization method, its selected at No-Auth and still my collections pass everytime

As explained in last message, when i select the Authorization method to Bearer token, by storing the access token in one variable and using for consecutive requests

**then today I got the error message that API access token has failed and re authenticate.**

So, I need help in these 2 situations

If you are ok, we can set up a call as well, because i have to demo this work at my client and then we decide if we want to go for Jira - Bitbucket or not?

Thanks again

Regards

Shallu


author: shallu_bassi_capgemini_com
body: Also could you please elaborate on

How to configure postman to do refresh the access token automatically, so that I can execute the schedule runs?

I have saved the access token received from a Get Request in a variable and use that for rest of the configurations with Authorization - \> Bearer Token


author: Patrik S
body: Hello [@shallu_bassi_capgemini_com](/t5/user/viewprofilepage/user-id/5133230) ,

Thank you very much for sharing the screenshots. I've removed one of the images as your API Key was visible. I would suggest rotating that API key for security reasons.

With the context of the screenshots, I was now able to have a better picture of the integration you are trying to build, and also reproduce the integration on my side.

In Postman, when you set up the connection of your API collection to a repository, it will redirect you to a Bitbucket page where you will be prompted to authorize Postman to have access to your repositories. On that page, when you click on Grant access, this will create an OAuth2 application for Postman to access your Bitbucket data, and this OAuth application is attached to your bitbucket account.

You can confirm that by:

1. Login on <https://bitbucket.org>

2. Clicking on your avatar in the top right corner and select **Personal Settings**

3. In the left side panel, select **App Authorizations**

4. A Postman V3 app should be listed.

The fact that this integration is attached to the bitbucket account that was used when connecting the repository has some implications:

* Postman will only have access to the repositories that the bitbucket account has and with the same level of permission
* The integration will break if the bitbucket account **Revoke** access to that application under **Personal settings \> App Authorizations**.

With that in mind, I can think of the following scenarios for the error you are receiving where the repository is disconnected on the Postman side :

* The access of the bitbucket account used to create the integration was changed (e.g account removed from a bitbucket group or direct access to repo) causing it to not have access to the repository, and hence Postman is not able to access the repository as well.
* The OAuth application under personal settings was manually revoked, so the authentication credentials Postman was using will become invalid and it will ask you to reconnect.

If you confirm the above scenarios are not happening in your case, I would assume there's a potential integration issue on Postman side on renewing the Access tokens from the OAuth application. In this case, I would suggest reaching out to [Postman support](https://www.postman.com/support/) as they are the developers of this integration.

Thank you, [@shallu_bassi_capgemini_com](/t5/user/viewprofilepage/user-id/5133230)

Patrik S


Tags: bitbucket-cloud

cloud