Skip to content
Back

GitHub OAuth Provider Session Missing `providerUid`

  • 0
  • Auth
  • Web
Saimon
10 Sep, 2025, 03:11

I’ve implemented a GitHub OAuth provider in Appwrite. Below is the code I used:

TypeScript
const handleGithubLogin = async () => {
  const { account } = await createClient();
  const session = account.createOAuth2Token({
    provider: OAuthProvider.Github,
    success: "http://localhost:3000/auth/callback",
    failure: "http://localhost:3000/login",
  });
  console.log("session", session);
  try {
  } catch (error) {
    console.log("error", error);
  }
};

useEffect(() => {
  const g = async () => {
    const secret = searchParams.get("secret");
    const userId = searchParams.get("userId");
    try {
      const session = await account.createSession({ userId, secret });
      console.log("session", session);
    } catch (error) {
      console.log("error login callback", error);
    }
  };
  g();
}, [searchParams]);

When I log the session, I get this response:

TypeScript
{
  "$id": "68c0e94c6b1bcde19a82",
  "$createdAt": "2025-09-10T02:58:20.441+00:00",
  "$updatedAt": "2025-09-10T02:58:20.441+00:00",
  "userId": "68c0e8fa19b89bd4df27",
  "expire": "2026-09-10T02:58:20.495+00:00",
  "provider": "oauth2",
  "providerUid": "",
  "providerAccessToken": "",
  "providerAccessTokenExpiry": "",
  "providerRefreshToken": "",
  "ip": "113.212.111.174",
  "osCode": "WIN",
  "osName": "Windows",
  "osVersion": "10",
  "clientType": "browser",
  "clientCode": "CH",
  "clientName": "Chrome",
  "clientVersion": "139.0",
  "clientEngine": "Blink",
  "clientEngineVersion": "139.0.0.0",
  "deviceName": "desktop",
  "countryCode": "bd",
  "countryName": "Bangladesh",
  "current": true,
  "factors": ["email"],
  "secret": "",
  "mfaUpdatedAt": ""
}

The problem is that providerUid is empty, even though the login seems successful.

👉 How can I properly retrieve the providerUid from the GitHub OAuth session?

TL;DR
Issue: GitHub OAuth Provider Session is missing `providerUid`. Solution: The `providerUid` field is empty in the GitHub OAuth session. To properly retrieve the `providerUid` from the GitHub OAuth session, ensure that the GitHub provider is returning a unique identifier for the user. This unique identifier needs to be set as the `providerUid` in the session to fetch it accurately. Check the GitHub OAuth configuration and verify that the `providerUid` is being correctly assigned during the authentication process.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more