[PR #1078] [MERGED] feat: facebook support accessToken & limited authenticationToken #3618

Closed
opened 2026-03-13 11:01:15 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/1078
Author: @reslear
Created: 12/31/2024
Status: Merged
Merged: 1/12/2025
Merged by: @Bekacru

Base: mainHead: patch-9


📝 Commits (8)

📊 Changes

1 file changed (+76 additions, -0 deletions)

View changed files

📝 packages/better-auth/src/social-providers/facebook.ts (+76 -0)

📄 Description

closes #555

  • supports accessToken, not validated, just go to next step getUserInfo
    i don't use for check token with (/debug_token Endpoint) to prevent this error:

    The request is invalid because the app is configured as a desktop app

    Native or desktop app?Enable if your app is a native or desktop app

  • facebook limited JWT authenticationToken checking with jose

Facebook use only accessToken namespace but we use verifyIdToken:

cc94e6a7c0/packages/better-auth/src/api/routes/sign-in.ts (L187-L188)

maybe in future need rename to universal name (e.g. verifyToken) and with all arguments, like:

verifyToken({ accessToken, token, nonce }) {

need pass both token and accessToken:

   idToken: {
      ...(Capacitor.getPlatform() === 'ios'
        ? {
            token,
          }
        : {
            token, // maybe on feature no need token 
            accessToken: token,
          }),
    },

edit: i open issue https://github.com/better-auth/better-auth/issues/1183

idToken example:

{
  profile: {
    iss: 'https://www.facebook.com',
    aud: '597901117421111',
    sub: '122151110914111111',
    iat: 1711153711,
    exp: 1736117311,
    jti: '8mbq.72183ed7254db11111aa647d74b03a553cbc111153fe9b293056b79b439a1e85',
    nonce: '02E61DB4-1111-485B-1111-F7EC838D5B26',
    email: 'test@mail.com',
    user_friends: [ '1111127124107079', '1111573044329708' ],
    given_name: 'Given',
    family_name: 'Family',
    name: 'Given Family',
    picture: 'https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=122158680914111111&height=100&width=100&ext=1739111197&hash=Abb6jpk31111D4e_tKCNR111'
  }
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/1078 **Author:** [@reslear](https://github.com/reslear) **Created:** 12/31/2024 **Status:** ✅ Merged **Merged:** 1/12/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `patch-9` --- ### 📝 Commits (8) - [`7e82c98`](https://github.com/better-auth/better-auth/commit/7e82c989686c25467ccaa71f9936ada7e5cfae81) feat: facebook support idToken (accessToken) & limited - [`6357d4a`](https://github.com/better-auth/better-auth/commit/6357d4a71a65c177b186ae5491be4a548c0e79ef) Update facebook.ts - [`d25f4aa`](https://github.com/better-auth/better-auth/commit/d25f4aa012722a03a7e88c35bdacf9f75b3e7228) Update facebook.ts - [`8c1e8ff`](https://github.com/better-auth/better-auth/commit/8c1e8ff24283e20654f677c4c71ebecd400bb41e) Update facebook.ts - [`e52f9a5`](https://github.com/better-auth/better-auth/commit/e52f9a58eb076f54f64084f28086d64fa027d4b9) Update facebook.ts - [`55408d6`](https://github.com/better-auth/better-auth/commit/55408d62d03b90f8f3c296912b43db225c47ae6e) style: format - [`eb00e4c`](https://github.com/better-auth/better-auth/commit/eb00e4c6c835a5e95b8476ade54443999652c2f6) Merge branch 'main' into patch-9 - [`150d14c`](https://github.com/better-auth/better-auth/commit/150d14cbb5b1c46d69573ab804774bc002bd63f2) refactor: simple structure ### 📊 Changes **1 file changed** (+76 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/social-providers/facebook.ts` (+76 -0) </details> ### 📄 Description closes #555 - [x] supports `accessToken`, not validated, just go to next step `getUserInfo` i don't use for check token with (/debug_token Endpoint) to prevent this error: > The request is invalid because the app is configured as a desktop app ![Native or desktop app?Enable if your app is a native or desktop app](https://github.com/user-attachments/assets/fbe1c044-90e8-4727-8af1-6b9616fd2fa5) - [x] facebook limited JWT `authenticationToken` checking with jose Facebook use only `accessToken` namespace but we use `verifyIdToken`: https://github.com/better-auth/better-auth/blob/cc94e6a7c07c5742938a15e6e340d3dde3de17b3/packages/better-auth/src/api/routes/sign-in.ts#L187-L188 maybe in future need rename to universal name (e.g. `verifyToken`) and with all arguments, like: ```ts verifyToken({ accessToken, token, nonce }) { ``` need pass both `token` and `accessToken`: ```ts idToken: { ...(Capacitor.getPlatform() === 'ios' ? { token, } : { token, // maybe on feature no need token accessToken: token, }), }, ``` edit: i open issue https://github.com/better-auth/better-auth/issues/1183 idToken example: ```js { profile: { iss: 'https://www.facebook.com', aud: '597901117421111', sub: '122151110914111111', iat: 1711153711, exp: 1736117311, jti: '8mbq.72183ed7254db11111aa647d74b03a553cbc111153fe9b293056b79b439a1e85', nonce: '02E61DB4-1111-485B-1111-F7EC838D5B26', email: 'test@mail.com', user_friends: [ '1111127124107079', '1111573044329708' ], given_name: 'Given', family_name: 'Family', name: 'Given Family', picture: 'https://platform-lookaside.fbsbx.com/platform/profilepic/?asid=122158680914111111&height=100&width=100&ext=1739111197&hash=Abb6jpk31111D4e_tKCNR111' } } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-03-13 11:01:15 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#3618