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 Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,931 views 7 10
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