BitBucket API for Users not returning repositories

I am using REST API to connect to BitBucket. I call into passing to it Consumer Key & Secret and it returns me access token. I then use that access token (as bearer) and pass it to my next API call

The returned JSON contains user name, etc but the repositories array is empty.

Where could I be going wrong?

My code is in Ruby:

 def GetUserAccess(userEmail)
        url = ""

        reqObj = url, strAuth_Consumer_Key, strAuth_Consumer_Secret
        responseData = "grant_type=client_credentials"
        puts responseData
        #Returns access_token, scopes, expires_in & refresh_token.
        #scopes = "pipeline:write webhook snippet:write wiki issue:write pullrequest:write repository:admin project:write team:write account:write"

        accessToken = 'Bearer ' + JSON.parse(responseData)["access_token"]
        headers = {Authorization: accessToken, accept: :json}

        url = "{userEmail}"
        output = "BitBucket:".ljust(20)
            responseData = RestClient.get(url,headers)
            puts responseData
            #Returns User details which means user was found, but the repositories array is empty for all users.
            jsonObj = JSON.parse(responseData)
            output += "Has Access To Repos   "
            jsonObj["repositories"].each do |repo|
                output += repo["name"] + ",   "
        rescue RestClient::NotFound, TypeError => e
            output += "No Access"

        puts output

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,306 views 8 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you