From 4e6e507528a93be3d13f7cc3bf4249553274613b Mon Sep 17 00:00:00 2001 From: pilcrowOnPaper <80624252+pilcrowOnPaper@users.noreply.github.com> Date: Mon, 4 Sep 2023 19:41:49 +0900 Subject: [PATCH] Add email field to `FacebookUser` (#1068) --- .auri/$n5h6ktgf.md | 6 ++++++ documentation/content/oauth/providers/facebook.md | 3 +++ packages/oauth/src/providers/facebook.ts | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .auri/$n5h6ktgf.md diff --git a/.auri/$n5h6ktgf.md b/.auri/$n5h6ktgf.md new file mode 100644 index 000000000..0ee3bda63 --- /dev/null +++ b/.auri/$n5h6ktgf.md @@ -0,0 +1,6 @@ +--- +package: "@lucia-auth/oauth" # package name +type: "minor" # "major", "minor", "patch" +--- + +Add `email` field `FacebookUser` \ No newline at end of file diff --git a/documentation/content/oauth/providers/facebook.md b/documentation/content/oauth/providers/facebook.md index d673d0f7c..0ee8c107c 100644 --- a/documentation/content/oauth/providers/facebook.md +++ b/documentation/content/oauth/providers/facebook.md @@ -82,10 +82,13 @@ type FacebookTokens = { ### `FacebookUser` +`email` is only included if `email` scope if provided. + ```ts type FacebookUser = { id: string; name: string; + email?: string; picture: { data: { height: number; diff --git a/packages/oauth/src/providers/facebook.ts b/packages/oauth/src/providers/facebook.ts index 94fcaca0b..03084c758 100644 --- a/packages/oauth/src/providers/facebook.ts +++ b/packages/oauth/src/providers/facebook.ts @@ -105,7 +105,7 @@ export class FacebookUserAuth< const getFacebookUser = async (accessToken: string): Promise => { const requestUrl = createUrl("https://graph.facebook.com/me", { access_token: accessToken, - fields: ["id", "name", "picture"].join(",") + fields: ["id", "name", "picture", "email"].join(",") }); const request = new Request(requestUrl, { headers: { @@ -125,6 +125,7 @@ export type FacebookTokens = { export type FacebookUser = { id: string; name: string; + email?: string; picture: { data: { height: number;