Getting generic_oauth working with bitbucket

Trying to get generic_oauth working with bitbucket.
My config is:
enabled = true
name = OAuth
allow_sign_up = true
client_id = some_id
client_secret = some_secret
scopes = ’ ’
auth_url = Log in with Atlassian account
token_url =
api_url = ://
;team_ids =
;allowed_organizations =

(sorry I had to remove the http from the front of api_url because “New users can only post 2 links”)
I keep getting an error:

t=2017-04-28T13:22:27+0000 lvl=eror msg="login.OAuthLogin(get info from generic_oauth)" logger=context userId=0 orgId=0 uname= error="json: cannot unmarshal object into Go value of type []social.Record"

if I change the scope to account, i get same error, if I change it or leave it default I get unkown scope error.

Any help would be awesome.


It sounds like your api_url output doesn’t include an email field, or an email:primary entry in the attributes object. Try changing the scopes setting to 'account email' and see if that resolves the problem.

Hi dcech,

No the api only returns the following:

{“repositories”: [], “user”: {“username”: “wonderphil”, “first_name”: “Philip”, “last_name”: “Davies”, “display_name”: “Philip Davies”, “is_staff”: false, “avatar”: “”, “resource_uri”: “/1.0/users/wonderphil”, “is_team”: false}}

Did you try changing the scopes? Grafana expects an email address for each user, so if it can’t locate one in the data returned from <api_url> it tries to load <api_url>/emails which it expects to return a list of objects containing email and primary attributes.

So I change the scope to ‘account email’ and I got the same thing. But if I also change api_url to along with scope to ‘account email’ i get this error:

t=2017-04-28T16:47:36+0000 lvl=eror msg=“login.OAuthLogin(get info from generic_oauth)” logger=context userId=0 orgId=0 uname= error=“invalid character ‘N’ looking for beginning of value”

the differen API url provides the following:
[{“active”: true, “is_atlassian_id”: true, “email”: "", “primary”: true}]

Ok, so Bitbucket is close to working with api_url =, but the format it returns from that endpoint includes display_name instead of name, and the /2.0/user/emails endpoint also returns incompatible json.

The good news is that in the process of figuring out what was going on I put together this patch, so it should be supported by Grafana in an upcoming release.

1 Like

Thanks, for your help with this. Any of ETA on when next release will be.