MCPcopy
hub / github.com/AgentOps-AI/agentops / auth_oauth

Function auth_oauth

app/api/agentops/auth/views.py:458–493  ·  view source on GitHub ↗

Redirects the user to the OAuth provider for authentication.

(request: Request, body: OAuthSchema)

Source from the content-addressed store, hash-verified

456
457@public_route
458async def auth_oauth(request: Request, body: OAuthSchema) -> RedirectMessageResponse:
459 """
460 Redirects the user to the OAuth provider for authentication.
461 """
462 supabase = get_supabase()
463 provider = body.provider
464 redirect_url = f"{API_URL}{reverse_path('auth_code')}"
465
466 if provider not in OAUTH_SCOPES:
467 raise AuthException(f"Unsupported OAuth provider: {provider}")
468
469 # TODO re-enable this once invalid redirect destinations have been fixed in `auth_code`
470 # if body.redirect_to:
471 # params = urllib.parse.urlencode({"redirect_to": body.redirect_to})
472 # redirect_url += f"?redirect_to={params}"
473
474 try:
475 auth_response = supabase.auth.sign_in_with_oauth(
476 {
477 'provider': provider,
478 'options': {
479 'redirect_to': redirect_url,
480 'scopes': OAUTH_SCOPES[provider],
481 },
482 }
483 )
484 except gotrue.errors.AuthApiError as e:
485 raise AuthException.from_gotrue_autherror(e)
486
487 if hasattr(auth_response, 'error'):
488 raise AuthException("Failed to initiate OAuth flow.")
489
490 return RedirectMessageResponse(
491 message="Redirecting to OAuth provider...",
492 url=auth_response.url,
493 )
494
495
496@public_route

Callers

nothing calls this directly

Calls 5

get_supabaseFunction · 0.90
reverse_pathFunction · 0.90
AuthExceptionClass · 0.85
from_gotrue_autherrorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…