Got 401 response when retrieving user teams

Issue #11162 resolved
chennanfei
created an issue

I has developed my CI service via Bitbucket APIs and blocked by one API "https://api.bitbucket.org/2.0/teams?role=member", I always got 401 response. I tested other API such as "https://api.bitbucket.org/2.0/teams/<team_name>;" and got expected result. The API worked fine few days ago but is blocking now.

I use python module 'rauth 0.7.1'. The test code is very simple.

from rauth import OAuth1Service

# Create a new consumer at https://bitbucket.org/account/user/{username}/api
CONSUMER_KEY = '<customer key>'
CONSUMER_SECRET = '<customer secret>'

# API URLs from https://confluence.atlassian.com/display/BITBUCKET/oauth+Endpoint
REQUEST_TOKEN_URL = 'https://bitbucket.org/!api/1.0/oauth/request_token'
ACCESS_TOKEN_URL = 'https://bitbucket.org/!api/1.0/oauth/access_token'
AUTHORIZE_URL = 'https://bitbucket.org/!api/1.0/oauth/authenticate'


def get_service():
    # Create the service
    return OAuth1Service(name='bitbucket',
                         consumer_key=CONSUMER_KEY,
                         consumer_secret=CONSUMER_SECRET,
                         request_token_url=REQUEST_TOKEN_URL,
                         access_token_url=ACCESS_TOKEN_URL,
                         authorize_url=AUTHORIZE_URL)


def get_session():
    access_token = '<access token>'
    access_token_secret = '<access token secret>'
    return get_service().get_session(token=(access_token, access_token_secret))


session = get_session()
url = 'https://api.bitbucket.org/2.0/teams/<team_name>' # work FINE
url = 'https://api.bitbucket.org/2.0/teams?role=member' # NOT work
resp = session.get(url)
print 'status={}, content={}'.format(resp.status_code, resp.text)

Comments (3)

  1. Log in to comment