Skip to content

Commit

Permalink
fix oauth callback endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
adlius committed Aug 30, 2024
1 parent b6fb7a0 commit 42f8028
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions website/oauth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ def oauth_connect(service_name, auth):

@must_be_logged_in
def oauth_callback(service_name, auth):
provider = get_service(service_name)
if flag_is_active(request, features.ENABLE_GV):
_forward_to_addon_service()
if provider._oauth_version == 1:
_forward_to_addon_service('oauth1')
elif provider._oauth_version == 2:
_forward_to_addon_service('oauth2')
return {}

user = auth.user
provider = get_service(service_name)

# Retrieve permanent credentials from provider
if not provider.auth_callback(user=user):
Expand All @@ -67,12 +70,12 @@ def oauth_callback(service_name, auth):

return {}

def _forward_to_addon_service():
def _forward_to_addon_service(oauth_version):
code = request.args.get('code')
state = request.args.get('state')
query_params = {
'code': code,
'state': state,
}
gv_url = urlunparse(urlparse(GRAVYVALET_URL)._replace(path='/v1/oauth/callback', query=urlencode(query_params)))
gv_url = urlunparse(urlparse(GRAVYVALET_URL)._replace(path=f'/v1/{oauth_version}/callback', query=urlencode(query_params)))
requests.get(gv_url)

0 comments on commit 42f8028

Please sign in to comment.