supabase / auth

A JWT based API for managing users and issuing JWT tokens

Home Page:https://supabase.com/docs/guides/auth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OAuth redirecting to supabase dashboard

Dragonslayer42069 opened this issue · comments

I am trying to implement Apple login in my self-hosted Supabase instance. Here are my details in the docker-compose file:

GOTRUE_EXTERNAL_APPLE_ENABLED: true
GOTRUE_EXTERNAL_APPLE_CLIENT_ID: MYIDENTIFIER
GOTRUE_EXTERNAL_APPLE_SECRET: MYKEY
GOTRUE_EXTERNAL_APPLE_REDIRECT_URI: https://db.domain.com/auth/v1/callback

When I start the login process, I am redirected to Apple. After a successful login on the Apple page, I am directed to my dashboard at https://db.domain.com/project/default?code=95cbab2b-296e-4a02-ba9a-9acb81feab20. However, no further redirection to domain.com occurs.

Here's the call in my app:

async function signInApple() {
    const { data } = await supabase.auth.signInWithOAuth({
        provider: 'apple',
        options: { redirectTo: `https://domain.com/auth/callback` }
    });
}

Auth logs:

[
  {
    "component": "api",
    "level": "info",
    "method": "GET",
    "msg": "request started",
    "path": "/authorize",
    "referer": "https://db.domain.com",
    "remote_addr": "XXXX",
    "time": "2024-01-26T10:49:21Z",
    "timestamp": "2024-01-26T10:49:21Z"
  }
]


 [
  {
    "component": "api",
    "level": "info",
    "method": "GET",
    "msg": "Redirecting to external provider",
    "path": "/authorize",
    "provider": "apple",
    "referer": "https://db.domain.com",
    "remote_addr": "XXX",
    "time": "2024-01-26T10:49:22Z",
    "timestamp": "2024-01-26T10:49:21Z"
  }
]

[
  {
    "component": "api",
    "duration": 713910242,
    "level": "info",
    "method": "GET",
    "msg": "request completed",
    "path": "/authorize",
    "referer": "https://db.domain.com",
    "remote_addr": "XXXX",
    "status": 302,
    "time": "2024-01-26T10:49:22Z",
    "timestamp": "2024-01-26T10:49:21Z"
  }
]

[
  {
    "component": "api",
    "level": "info",
    "method": "POST",
    "msg": "request started",
    "path": "/callback",
    "referer": "https://db.domain.com",
    "remote_addr": "XXX",
    "time": "2024-01-26T10:49:34Z",
    "timestamp": "2024-01-26T10:49:34Z"
  }
]

[
  {
    "auth_event": [
      {
        "action": "login",
        "actor_id": "92099762-e619-460e-866ee4636",
        "actor_name": "MY NAME",
        "actor_username": "mymail@mail.com",
        "actor_via_sso": false,
        "log_type": "account",
        "traits": [
          {
            "provider": "apple"
          }
        ]
      }
    ],
    "component": "api",
    "duration": 977380207,
    "level": "info",
    "method": "POST",
    "msg": "request completed",
    "path": "/callback",
    "referer": "https://db.domain.com",
    "remote_addr": "XXX",
    "status": 302,
    "time": "2024-01-26T10:49:35Z",
    "timestamp": "2024-01-26T10:49:34Z"
  }
]

Found my mistake.
In my .env I defined

SITE_URL=https://db.domain.com

but it has to be

SITE_URL=https://domain.com

Hey @Dragonslayer42069,

Thanks for updating! Glad the issue was resolved - going to close for now but let us know if there are any further issues