Hi,
I created an application link on Confluence and am able to get the token and secret for oauth. When I try to use the token/secret in the Atlassain Confluence python api, it doesn't work. I am able to upload an attachment using basic authentication.
Here is my code
import requests
from requests_oauthlib import OAuth1
from oauthlib.oauth1 import SIGNATURE_HMAC, SIGNATURE_RSA
from requests_oauthlib import OAuth1Session
from atlassian import Confluence
key = open("confluence_privatekey.pem").read()
pkeystring=key.strip()
print (pkeystring)
oauth = OAuth1Session('oauthkey', client_secret='oauthsecret',signature_method=SIGNATURE_RSA, rsa_key=pkeystring)
####this call is working
fetch_response = oauth.fetch_request_token('https://xyz.atlassian.net/wiki/plugins/servlet/oauth/request-token')
access_token = fetch_response.get('oauth_token')
access_token_secret = fetch_response.get('oauth_token_secret')
print(fetch_response)
oauth_dict = {
'access_token': access_token,
'access_token_secret': access_token_secret,
'consumer_key': 'oauthkey',
'key_cert': pkeystring}
print(oauth_dict)
confluence = Confluence(url='https://xyz.atlassian.net/wiki', oauth=oauth_dict)
### this call fails but works with basic authentication
zz = confluence.attach_file("text1.txt", name='text1.txt', page_id='1234')
I get this error:
File "C:\Users\dbhatia\PycharmProjects\LearnModule\venv\lib\site-packages\atlassian\confluence.py", line 522, in attach_file
comment=comment)
File "C:\Users\dbhatia\PycharmProjects\LearnModule\venv\lib\site-packages\atlassian\confluence.py", line 484, in attach_content
if attachments.get('size'):
AttributeError: 'str' object has no attribute 'get'
Hi Deepika,
I would suggest reaching out to the Developer Community:
https://community.developer.atlassian.com/
There you will be able to get better support for your development queries.
Cheers,
Paulo
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.