Skip to content

Commit

Permalink
Use SOCIALACCOUNT_PROVIDERS settings
Browse files Browse the repository at this point in the history
  • Loading branch information
saily committed Dec 18, 2015
1 parent 24fcdd9 commit d679ce0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 27 deletions.
3 changes: 2 additions & 1 deletion allauth/socialaccount/providers/gitlab/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@


class GitLabAccount(ProviderAccount):

def get_profile_url(self):
return self.account.extra_data.get('web_url')
return self.account.extra_data.get('html_url')

def get_avatar_url(self):
return self.account.extra_data.get('avatar_url')
Expand Down
19 changes: 9 additions & 10 deletions allauth/socialaccount/providers/gitlab/views.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
# -*- coding: utf-8 -*-
from allauth.socialaccount import app_settings
from allauth.socialaccount.providers.gitlab.provider import GitLabProvider
from allauth.socialaccount.providers.oauth2.views import OAuth2Adapter
from allauth.socialaccount.providers.oauth2.views import OAuth2CallbackView
from allauth.socialaccount.providers.oauth2.views import OAuth2LoginView
from django.conf import settings

import requests


class GitLabOAuth2Adapter(OAuth2Adapter):
provider_id = GitLabProvider.id
provider_default_url = 'https://gitlab.com'
provider_api_version = 'v3'

access_token_url = getattr(
settings, 'GITLAB_ACCESS_TOKEN_URL', 'https://gitlab.com/oauth/token'
)

authorize_url = getattr(
settings, 'GITLAB_USER_AUTHORIZATION_URL', 'https://gitlab.com/oauth/authorize' # noqa
)
settings = app_settings.PROVIDERS.get(provider_id, {})
provider_base_url = settings.get('GITLAB_URL', provider_default_url)

profile_url = getattr(
settings, 'GITLAB_USER_INFO_URL', 'https://gitlab.com/api/v3/user'
access_token_url = '{0}/oauth/token'.format(provider_base_url)
authorize_url = '{0}/oauth/authorize'.format(provider_base_url)
profile_url = '{0}/api/{1}/user'.format(
provider_base_url, provider_api_version
)

def complete_login(self, request, app, token, response):
Expand Down
21 changes: 5 additions & 16 deletions docs/providers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,25 +255,14 @@ authentication provider as described in GitLab docs here:

http://doc.gitlab.com/ce/integration/oauth_provider.html

Following GitLab settings are available:
Following GitLab settings are available, it unset https://gitlab.com will
be used.

GITLAB_USER_AUTHORIZATION_URL:
Override authorize endpoint to request an authorization token. For your
GITLAB_URL:
Override endpoint to request an authorization and access token. For your
private GitLab server you use:

https://your.gitlab.server.tld/oauth/authorize

GITLAB_ACCESS_TOKEN_URL:
To request the access token from your private GitLab server you have to
override access token endpoint:

https://your.gitlab.server.tld/oauth/token

GITLAB_USER_INFO_URL:
Endpoint to retrieve your user information from. For your private GitLab
server you use:

https://your.gitlab.server.tld/api/v3/user
https://your.gitlab.server.tld


Google
Expand Down

0 comments on commit d679ce0

Please sign in to comment.