I have created a new addon and have installed the add-on successfully. An atlassianHost is created with base url https://bitbucket.org.
Now within incoming request, I need to make a request to bitbucket rest api whose base url is https://api.bitbucket.org. When making the request with AtlassianHostRestClients, the out going request does not get signed with the JWT tokens as there is no AtlassianHost with the base url.
Because of this I get a 403 access forbidden response.
I am able to successfully get the incoming calls authenticated and the AtlassianHost entry is created fine. Its just that when I make a call to api.bitbucket.org that I get a 401.
Can you please share a code snippet on how you call http://api.bitbucket.org/ ? Kindly replace any credentials that you use. I’ll try to replicate on my end.
I did a little more digging around. The problem seems to be in the method getHostFromRequestUrl. Apparently the code only allows requests to the base url when using AtlassianHostRestClients. I tried to use a separate rest client to directly make the call by creating a jwt token. But even this requires the base url to be used for creating the token.
Apologies, I’m not particularly familiar developing Bitbucket cloud apps with Spring. AFAIK, the scaffold Spring Connect Integration project is specifically for Jira and Confluence. For Bitbucket, as they have different set of format, you could use the Connect framework and there it automatically generates the token for you.
But if you want to use Spring and Java in this case, then my best bet is for you is to use Atlassian’s JWT library for Java: Atlassian JWT Libriaries