{"type":"rich","version":"1.0","provider_name":"phorkie","provider_url":"https:\/\/p.cweiske.de\/","title":"Atlassian access tokens and REST API endpoints ","author_name":"Christian Weiske","cache_age":86400,"width":900,"height":900,"html":"<!-- embedding all files of https:\/\/p.cweiske.de\/969 -->\n<link rel=\"stylesheet\" href=\"https:\/\/p.cweiske.de\/css\/embed.css\"\/>\n<div class=\"phork\" id=\"969\">\n    <div class=\"phork-file\">\n <div class=\"phork-content\">\n  \n<div class=\"document\">\n\n\n<p>Atlassian's cloud products have REST APIs, but accessing them with tokens is a major pain - the base URL is different depending on the token type, and confluence API v2 documentation misses the API prefix.<\/p>\n<div class=\"section\" id=\"scoped-vs-unscoped-tokens\">\n<h1>Scoped vs. unscoped tokens<\/h1>\n<p>Access tokens created via <a class=\"reference external\" href=\"https:\/\/id.atlassian.com\/manage-profile\/security\/api-tokens\">https:\/\/id.atlassian.com\/manage-profile\/security\/api-tokens<\/a> come in two flavors: scoped and unscoped.<\/p>\n<p>When using an unscoped token, you have to use <tt class=\"docutils literal\"><span class=\"pre\">https:\/\/customername.atlassian.net\/<\/span><\/tt> as API domain.<\/p>\n<p>Scoped tokens need a different domain and path: <tt class=\"docutils literal\"><span class=\"pre\">https:\/\/api.atlassian.com\/ex\/confluence\/&lt;cloudid&gt;\/<\/span><\/tt>.\nCloud ID can be found at <tt class=\"docutils literal\"><span class=\"pre\">https:\/\/customername.atlassian.net\/_edge\/tenant_info<\/span><\/tt>.<\/p>\n<p>Source: <a class=\"reference external\" href=\"https:\/\/support.atlassian.com\/confluence\/kb\/scoped-api-tokens-in-confluence-cloud\">https:\/\/support.atlassian.com\/confluence\/kb\/scoped-api-tokens-in-confluence-cloud<\/a><\/p>\n<\/div>\n<div class=\"section\" id=\"rest-api-v1-vs-v2\">\n<h1>REST API v1 vs. v2<\/h1>\n<p>Links:<\/p>\n<ul class=\"simple\">\n<li>Confluence Spaces REST API v1: <a class=\"reference external\" href=\"https:\/\/developer.atlassian.com\/cloud\/confluence\/rest\/v1\/api-group-space\/\">https:\/\/developer.atlassian.com\/cloud\/confluence\/rest\/v1\/api-group-space\/<\/a><\/li>\n<li>Confluence Spaces REST API v2: <a class=\"reference external\" href=\"https:\/\/developer.atlassian.com\/cloud\/confluence\/rest\/v2\/api-group-space\/\">https:\/\/developer.atlassian.com\/cloud\/confluence\/rest\/v2\/api-group-space\/<\/a><\/li>\n<\/ul>\n<p>Documentation for v1 lists the whole path: <tt class=\"docutils literal\">POST \/wiki\/rest\/api\/space<\/tt>. Just use the base URL + the path used here, e.g. <tt class=\"docutils literal\"><span class=\"pre\">https:\/\/customername.atlassian.net\/wiki\/rest\/api\/space<\/span><\/tt>.<\/p>\n<p>Documentation for v2 misses some crucial bits, it only lists <tt class=\"docutils literal\">GET \/spaces<\/tt>. Appending that to the base URL will yield a 404.\nThe solution is to put <tt class=\"docutils literal\">\/wiki\/api\/v2\/<\/tt> between the base URL and the path given in the docs: <tt class=\"docutils literal\"><span class=\"pre\">https:\/\/customername.atlassian.net\/wiki\/api\/v2\/spaces<\/span><\/tt>.<\/p>\n<ul class=\"simple\">\n<li>v1 path: <tt class=\"docutils literal\">\/wiki\/rest\/api\/<\/tt><\/li>\n<li>v2 path: <tt class=\"docutils literal\">\/wiki\/api\/v2\/<\/tt><\/li>\n<\/ul>\n<p>Passing tokens via HTTP Basic Auth is possible in REST API v1 <em>and<\/em> v2.<\/p>\n<\/div>\n<div class=\"section\" id=\"spaces-api-example\">\n<h1>Spaces API example<\/h1>\n<ul class=\"simple\">\n<li>v1 + unscoped token: <tt class=\"docutils literal\"><span class=\"pre\">https:\/\/customername.atlassian.net\/wiki\/rest\/api\/space<\/span><\/tt><\/li>\n<li>v1 + scoped token: <tt class=\"docutils literal\"><span class=\"pre\">https:\/\/api.atlassian.com\/ex\/confluence\/&lt;cloudid&gt;\/wiki\/rest\/api\/space<\/span><\/tt><\/li>\n<li>v2 + unscoped token: <tt class=\"docutils literal\"><span class=\"pre\">https:\/\/customername.atlassian.net\/wiki\/api\/v2\/spaces<\/span><\/tt><\/li>\n<li>v2 + scoped token: <tt class=\"docutils literal\"><span class=\"pre\">https:\/\/api.atlassian.com\/ex\/confluence\/&lt;cloudid&gt;\/wiki\/api\/v2\/spaces<\/span><\/tt><\/li>\n<\/ul>\n<\/div>\n<\/div>\n\n <\/div>\n <div class=\"phork-meta\">\n  <a href=\"https:\/\/p.cweiske.de\/969\/rev-raw\/aa66b403c47bc7f07f4281fe260f8a6b89d23c22\/README.rst\" style=\"float: right\">view raw source<\/a>\n  <a href=\"https:\/\/p.cweiske.de\/969#README.rst\">README.rst<\/a>\n <\/div>\n<\/div>\n<\/div>\n"}
