【问题标题】:access confluence page via python script通过 python 脚本访问 confluence 页面
【发布时间】:2020-08-03 15:06:46
【问题描述】:

我需要通过 python 脚本访问 Confluence 页面,但是虽然我在网上找到了一些示例,但我无法做到。

这里有一些尝试:

import requests

urllogin = 'https://myorg/confluence/display/path/to/page'
login = requests.get(urllogin, auth=('myusername', 'mytoken'))
print(login.status_code)
from atlassian import Confluence

confluence = Confluence(
    url='https://myorg/confluence/display/path/to/page',
    username='myusername',
    password='mytoken')

这似乎不是令牌问题:我尝试使用 Atlassian API 令牌 https://id.atlassian.com/manage-profile/security/api-tokensGoogle API token(我的组织也使用 Google 凭据访问 Confluence)。使用登录凭据也不起作用。

【问题讨论】:

    标签: python-3.x google-oauth confluence confluence-rest-api atlassian-python-api


    【解决方案1】:

    您的尝试有两个问题。

    首先,url 需要是您的融合站点的基本 url,所以在您的情况下,类似于 url='https://conf.myorg.com'

    其次,使用参数username=password= 用于基本身份验证。但我猜你想要 OAuth?还是您所指的令牌是 Atlassian API 令牌?无论哪种方式,overview of all different authentication modes can be found in the documentation。以下示例取自那里。

    OAuth:

    from atlassian import Confluence
    
    oauth_dict = {
        'access_token': 'access_token',
        'access_token_secret': 'access_token_secret',
        'consumer_key': 'consumer_key',
        'key_cert': 'key_cert'}
    
    confluence = Confluence(
        url='http://localhost:8090',
        oauth=oauth_dict)
    

    API 令牌:

    from atlassian import Confluence
    
    # Obtain an API token from: https://id.atlassian.com/manage-profile/security/api-tokens
    # You cannot log-in with your regular password to these services.
    
    confluence = Confluence(
        url='https://your-domain.atlassian.net',
        username=jira_username,
        password=jira_api_token,
        cloud=True)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-03
      • 2016-12-25
      • 1970-01-01
      • 1970-01-01
      • 2019-05-18
      • 1970-01-01
      • 2017-05-09
      相关资源
      最近更新 更多