Uploaded image for project: 'Bitbucket Cloud'
  1. Bitbucket Cloud
  2. BCLOUD-11162

Got 401 response when retrieving user teams

    XMLWordPrintable

    Details

      Description

      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.

      #!python
      
      
      from rauth import OAuth1Service
      
      # Create a new consumer at https://bitbucket.org/account/user/{username}/api
      CONSUMER_KEY = &#x27;<customer key>&#x27;
      CONSUMER_SECRET = &#x27;<customer secret>&#x27;
      
      # API URLs from https://confluence.atlassian.com/display/BITBUCKET/oauth+Endpoint
      REQUEST_TOKEN_URL = &#x27;https://bitbucket.org/!api/1.0/oauth/request_token&#x27;
      ACCESS_TOKEN_URL = &#x27;https://bitbucket.org/!api/1.0/oauth/access_token&#x27;
      AUTHORIZE_URL = &#x27;https://bitbucket.org/!api/1.0/oauth/authenticate&#x27;
      
      
      def get_service():
          # Create the service
          return OAuth1Service(name=&#x27;bitbucket&#x27;,
                               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 = &#x27;<access token>&#x27;
          access_token_secret = &#x27;<access token secret>&#x27;
          return get_service().get_session(token=(access_token, access_token_secret))
      
      
      session = get_session()
      url = &#x27;https://api.bitbucket.org/2.0/teams/<team_name>&#x27; # work FINE
      url = &#x27;https://api.bitbucket.org/2.0/teams?role=member&#x27; # NOT work
      resp = session.get(url)
      print &#x27;status={}, content={}&#x27;.format(resp.status_code, resp.text)
      
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            2c6177f749cc Nanfei Chen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: