Hi - I am trying to connect to Confluence with the Atlassian python API using Oauth 2.0 with a bearer token as required by my company because we have our own domain and use multi-factor authentication.
The link below shows the different authentication methods.
https://atlassian-python-api.readthedocs.io/index.html
I have tested my token and URL using the below on the command line and it works (token and content shown below are fake)
curl -H "Authorization: Bearer XYMWODLW" https://wiki.mycompany.com/rest/api/content/123
I am having trouble translating this to one of the authentication methods in the link. Bearer tokens are typical in Oauth 2.0. When I reference the Oauth 2.0 section, I get the below code.
from atlassian.bitbucket import Cloud # token is a dictionary and must at least contain "access_token" # and "token_type". oauth2_dict = { "client_id": client_id, "token": token} bitbucket_cloud = Cloud( oauth2=oauth2_dict) # For a detailed example see bitbucket_oauth2.py in # examples/bitbucket
My questions:
1. Does this also work for Confluence?
2. Where do I get client_id?
3. What is the actual format? Example shown below. (I was unable to find bitbucket_oauth2.py to reference)
oauth2_dict = { "client_id": client_id,
"token": {"access_token" : "XYMWODLW",
"token_type" : "Bearer"
}
}
Hi, I have solved my above issue and wanted to report back the solution in case it helps anyone else.
import requests
from atlassian import Confluence
s = requests.Session()
s.headers['Authorization'] = 'Bearer XYMWODLW'
confluence = Confluence(url='https://wiki.mycompany.com/', session=s)
Then you can use the methods in the python API wrapper
https://atlassian-python-api.readthedocs.io/index.html
confluence.get_page_space('123')
(Fake bearer token above)
Reference:
https://github.com/atlassian-api/atlassian-python-api/issues/467
Hi @equigley2 ,
I have the same issue. I get the error: HTTPError: Current user not permitted to use Confluence
To get the Bearer Token, did you simply follow the documentation ?
I also checked the scopes in the Developer Console and added as much as possible without success. Any insights are more than welcome.
Thanks in advance
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi , @equigley2 @Yasir Kusay I am attempting what I think is the same code, but still getting an HTTPError. My code looks like
The scopes returned from accessible resources from the token looked like:
#readonly:content.attachment:confluence
#read:confluence-content.all
#read:confluence-content.summary
#read:confluence-user
#search:confluence
#read:confluence-space.summary
so I don't think it's a permissions issue.
Is there anything you guys did differently to get it working?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
UPDATE: I have found the solution finally. Since Atlassian's python client library now points to the v2 API, the url passed to Confluence.__init__ needs to be structured like
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.