Sign in with Apple errors after account is created #286

Closed
opened 2026-03-13 07:40:47 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @mandrillxx on GitHub (Nov 27, 2024).

Describe the bug
After creating an account using authClient.signIn.social with the apple provider and the idToken, it works. However, after the account is created an error is produced on the server.

To Reproduce
Steps to reproduce the behavior:

// continue-with-apple.tsx
import { useColorScheme } from "@/hooks/use-color-scheme";
import { authClient } from "@/lib/auth";
import * as AppleAuthentication from "expo-apple-authentication";
import { Platform } from "react-native";

export function ContinueWithApple() {
  const { isDarkColorScheme } = useColorScheme();
  if (Platform.OS !== "ios") {
    return null;
  }

  return (
    <AppleAuthentication.AppleAuthenticationButton
      buttonType={AppleAuthentication.AppleAuthenticationButtonType.CONTINUE}
      buttonStyle={
        isDarkColorScheme
          ? AppleAuthentication.AppleAuthenticationButtonStyle.BLACK
          : AppleAuthentication.AppleAuthenticationButtonStyle.WHITE
      }
      cornerRadius={5}
      style={{ width: "100%", height: 48 }}
      onPress={async () => {
        try {
          const credential = await AppleAuthentication.signInAsync({
            requestedScopes: [
              AppleAuthentication.AppleAuthenticationScope.FULL_NAME,
              AppleAuthentication.AppleAuthenticationScope.EMAIL,
            ],
          });
          if (credential.identityToken) {
            await authClient.signIn.social({
              provider: "apple",
              idToken: {
                token: credential.identityToken,
              },
            });
          } else {
            throw new Error("No identityToken.");
          }
        } catch (e) {
          // handle errors
        }
      }}
    />
  );
}

the above works if the account isn't created, however if it is created this error shows

ERROR   Error No values to set                                                                                                                         Better Auth

  at mapUpdateSet (.next\server\chunks\08b5e_drizzle-orm_5fd9ac._.js:1560:15)
  at PgUpdateBuilder.set (.next\server\chunks\08b5e_drizzle-orm_5fd9ac._.js:7266:231)
  at Object.update (.next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:14406:122)
  at s (.next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:3345:79)
  at Object.updateAccount (.next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:3782:44)
  at ue (.next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:1563:48)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async .next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:1749:17
  at async handle (.next\server\chunks\08b5e_5c7339._.js:3304:23)
  at async Te.a.<computed> (.next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:3197:17)
  at async handler (.next\server\chunks\08b5e_5c7339._.js:3514:32)
  at async handler (.next\server\chunks\08b5e_5c7339._.js:3565:25)
  at async AppRouteRouteModule.do (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:10:33313)
  at async AppRouteRouteModule.handle (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:10:40382)
  at async doRender (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:1455:42)
  at async responseGenerator (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:1814:28)
  at async DevServer.renderToResponseWithComponentsImpl (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:1824:28)
  at async DevServer.renderPageComponent (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:2240:24)
  at async DevServer.renderToResponseImpl (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:2278:32)
  at async DevServer.pipeImpl (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:960:25)
  at async NextNodeServer.handleCatchallRenderRequest (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\next-server.js:281:17)  
  at async DevServer.handleRequestImpl (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:853:17)
  at async C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\dev\next-dev-server.js:373:20
  at async Span.traceAsyncFn (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\trace\trace.js:153:20)
  at async DevServer.handleRequest (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\dev\next-dev-server.js:370:24)
  at async invokeRender (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\lib\router-server.js:183:21)
  at async handleRequest (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\lib\router-server.js:360:24)
  at async requestHandlerImpl (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\lib\router-server.js:384:13)
  at async Server.requestListener (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\lib\start-server.js:142:13)

Expected behavior
It should sign in with the provider account

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11

Smartphone (please complete the following information):

  • Device: iPhone 15 Pro Max
  • OS: iOS 18.2
Originally created by @mandrillxx on GitHub (Nov 27, 2024). **Describe the bug** After creating an account using authClient.signIn.social with the apple provider and the idToken, it works. However, after the account is created an error is produced on the server. **To Reproduce** Steps to reproduce the behavior: ```ts // continue-with-apple.tsx import { useColorScheme } from "@/hooks/use-color-scheme"; import { authClient } from "@/lib/auth"; import * as AppleAuthentication from "expo-apple-authentication"; import { Platform } from "react-native"; export function ContinueWithApple() { const { isDarkColorScheme } = useColorScheme(); if (Platform.OS !== "ios") { return null; } return ( <AppleAuthentication.AppleAuthenticationButton buttonType={AppleAuthentication.AppleAuthenticationButtonType.CONTINUE} buttonStyle={ isDarkColorScheme ? AppleAuthentication.AppleAuthenticationButtonStyle.BLACK : AppleAuthentication.AppleAuthenticationButtonStyle.WHITE } cornerRadius={5} style={{ width: "100%", height: 48 }} onPress={async () => { try { const credential = await AppleAuthentication.signInAsync({ requestedScopes: [ AppleAuthentication.AppleAuthenticationScope.FULL_NAME, AppleAuthentication.AppleAuthenticationScope.EMAIL, ], }); if (credential.identityToken) { await authClient.signIn.social({ provider: "apple", idToken: { token: credential.identityToken, }, }); } else { throw new Error("No identityToken."); } } catch (e) { // handle errors } }} /> ); } ``` the above works if the account isn't created, however if it is created this error shows ``` ERROR Error No values to set Better Auth at mapUpdateSet (.next\server\chunks\08b5e_drizzle-orm_5fd9ac._.js:1560:15) at PgUpdateBuilder.set (.next\server\chunks\08b5e_drizzle-orm_5fd9ac._.js:7266:231) at Object.update (.next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:14406:122) at s (.next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:3345:79) at Object.updateAccount (.next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:3782:44) at ue (.next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:1563:48) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async .next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:1749:17 at async handle (.next\server\chunks\08b5e_5c7339._.js:3304:23) at async Te.a.<computed> (.next\server\chunks\08b5e_better-auth_dist_e6b4e2._.js:3197:17) at async handler (.next\server\chunks\08b5e_5c7339._.js:3514:32) at async handler (.next\server\chunks\08b5e_5c7339._.js:3565:25) at async AppRouteRouteModule.do (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:10:33313) at async AppRouteRouteModule.handle (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\compiled\next-server\app-route.runtime.dev.js:10:40382) at async doRender (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:1455:42) at async responseGenerator (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:1814:28) at async DevServer.renderToResponseWithComponentsImpl (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:1824:28) at async DevServer.renderPageComponent (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:2240:24) at async DevServer.renderToResponseImpl (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:2278:32) at async DevServer.pipeImpl (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:960:25) at async NextNodeServer.handleCatchallRenderRequest (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\next-server.js:281:17) at async DevServer.handleRequestImpl (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\base-server.js:853:17) at async C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\dev\next-dev-server.js:373:20 at async Span.traceAsyncFn (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\trace\trace.js:153:20) at async DevServer.handleRequest (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\dev\next-dev-server.js:370:24) at async invokeRender (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\lib\router-server.js:183:21) at async handleRequest (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\lib\router-server.js:360:24) at async requestHandlerImpl (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\lib\router-server.js:384:13) at async Server.requestListener (C:\Users\lightest\Desktop\garange-refactor\garange-mono\node_modules\next\dist\server\lib\start-server.js:142:13) ``` **Expected behavior** It should sign in with the provider account **Screenshots** ![image](https://github.com/user-attachments/assets/60efae7a-fe2e-425f-8e89-cd80f409fc7d) **Desktop (please complete the following information):** - OS: Windows 11 **Smartphone (please complete the following information):** - Device: iPhone 15 Pro Max - OS: iOS 18.2
GiteaMirror added the help wantedgood first issue labels 2026-03-13 07:40:47 -05:00
Author
Owner

@pakenfit commented on GitHub (Nov 27, 2024):

Can you show response returned by await authClient.signIn.social ? Are you using nextjs routes ? And what db adapter are you using ?

@pakenfit commented on GitHub (Nov 27, 2024): Can you show response returned by await authClient.signIn.social ? Are you using nextjs routes ? And what db adapter are you using ?
Author
Owner

@mandrillxx commented on GitHub (Nov 27, 2024):

Can you show response returned by await authClient.signIn.social ? Are you using nextjs routes ? And what db adapter are you using ?

{
  "data": null,
  "error": {
    "status": 500,
    "statusText": ""
  }
}

Using turborepo, the backend is setup with a nextjs route and is being used by expo client. Using Drizzle adapter

@mandrillxx commented on GitHub (Nov 27, 2024): > Can you show response returned by await authClient.signIn.social ? Are you using nextjs routes ? And what db adapter are you using ? ```json { "data": null, "error": { "status": 500, "statusText": "" } } ``` Using turborepo, the backend is setup with a nextjs route and is being used by expo client. Using Drizzle adapter
Author
Owner

@luksch42 commented on GitHub (Nov 27, 2024):

Can you show response returned by await authClient.signIn.social ? Are you using nextjs routes ? And what db adapter are you using ?


{

  "data": null,

  "error": {

    "status": 500,

    "statusText": ""

  }

}

Using turborepo, the backend is setup with a nextjs route and is being used by expo client

I have the same issue. Same setup but with the drizzle adapter

@luksch42 commented on GitHub (Nov 27, 2024): > > Can you show response returned by await authClient.signIn.social ? Are you using nextjs routes ? And what db adapter are you using ? > > > > ```json > > { > > "data": null, > > "error": { > > "status": 500, > > "statusText": "" > > } > > } > > ``` > > > > Using turborepo, the backend is setup with a nextjs route and is being used by expo client I have the same issue. Same setup but with the drizzle adapter
Author
Owner

@mandrillxx commented on GitHub (Nov 27, 2024):

Can you show response returned by await authClient.signIn.social ? Are you using nextjs routes ? And what db adapter are you using ?

{

  "data": null,

  "error": {

    "status": 500,

    "statusText": ""

  }

}

Using turborepo, the backend is setup with a nextjs route and is being used by expo client

I have the same issue. Same setup but with the drizzle adapter

I'm using the drizzle adapter as well

@mandrillxx commented on GitHub (Nov 27, 2024): > > > Can you show response returned by await authClient.signIn.social ? Are you using nextjs routes ? And what db adapter are you using ? > > > > > > ```json > > { > > > > "data": null, > > > > "error": { > > > > "status": 500, > > > > "statusText": "" > > > > } > > > > } > > ``` > > > > > > > > > > > > > > > > > > > > > > > > Using turborepo, the backend is setup with a nextjs route and is being used by expo client > > I have the same issue. Same setup but with the drizzle adapter I'm using the drizzle adapter as well
Author
Owner

@pakenfit commented on GitHub (Nov 28, 2024):

Hey I could not be able to test with apple auth since I have an issue with my iphone the screen is not responding, but I tested using nextjs router and android using google auth with idToken. This is working fine. I am going to buy a new phone maybe I can test this weekend.

@pakenfit commented on GitHub (Nov 28, 2024): Hey I could not be able to test with apple auth since I have an issue with my iphone the screen is not responding, but I tested using `nextjs router` and `android` using `google auth with idToken`. This is working fine. I am going to buy a new phone maybe I can test this weekend.
Author
Owner

@luksch42 commented on GitHub (Nov 29, 2024):

This is the data used to update the account in link-account.ts when a user already exists:

{
  accessToken: undefined,
  idToken: undefined,
  refreshToken: undefined,
  accessTokenExpiresAt: undefined,
  refreshTokenExpiresAt: undefined,
  scope: undefined,
  providerId: 'apple',
  accountId: '00...',
  userId: '5DQ...',
  createdAt: '2024-11-29T14:22:05.749Z',
  updatedAt: '2024-11-29T14:22:05.749Z'
}

The updateAccount method only receives undefined values as inputs. The Drizzle adapter cannot handle this scenario and throws an error.

There are two possible solutions:

  1. Add a check in link-account.ts to verify if the updateData contains only undefined values.
  2. Modify the Drizzle adapter to handle such cases internally, if this issue is specific to the adapter.
@luksch42 commented on GitHub (Nov 29, 2024): This is the data used to update the account in `link-account.ts` when a user already exists: ```javascript { accessToken: undefined, idToken: undefined, refreshToken: undefined, accessTokenExpiresAt: undefined, refreshTokenExpiresAt: undefined, scope: undefined, providerId: 'apple', accountId: '00...', userId: '5DQ...', createdAt: '2024-11-29T14:22:05.749Z', updatedAt: '2024-11-29T14:22:05.749Z' } ``` The `updateAccount` method only receives `undefined` values as inputs. The Drizzle adapter cannot handle this scenario and throws an error. There are two possible solutions: 1. Add a check in `link-account.ts` to verify if the `updateData` contains only `undefined` values. 2. Modify the Drizzle adapter to handle such cases internally, if this issue is specific to the adapter.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#286