Skip to content

Commit 215e4dd

Browse files
committed
Get repos for the user’s BB name, not their RTD name :)
1 parent 976d117 commit 215e4dd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

readthedocs/oauth/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from django.conf import settings
66
from requests_oauthlib import OAuth1Session, OAuth2Session
7+
from allauth.socialaccount.models import SocialAccount
78

89
from .models import GithubProject, GithubOrganization, BitbucketProject
910
from readthedocs.restapi.client import api
@@ -152,13 +153,17 @@ def import_bitbucket(user, sync):
152153
""" Do the actual github import """
153154

154155
session = get_oauth_session(user, provider='bitbucket')
156+
try:
157+
social_account = user.socialaccount_set.get(provider='bitbucket')
158+
except SocialAccount.DoesNotExist:
159+
log.exception('User tried to import from Bitbucket without a Social Account')
155160
if sync and session:
156161
# Get user repos
157162
try:
158163
owner_resp = bitbucket_paginate(
159164
session,
160165
'https://bitbucket.org/api/2.0/repositories/{owner}'.format(
161-
owner=user.username))
166+
owner=social_account.uid))
162167
process_bitbucket_json(user, owner_resp)
163168
except TypeError, e:
164169
print e

0 commit comments

Comments
 (0)