diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 7f2c75e0..a98e9e15 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), ### Added +- Added the `Instagram` OAuth provider to the supported integrations in Aura Auth. [#209](https://github.com/aura-stack-ts/auth/pull/209) + - Added the `Authentik` OpenID Connect provider, enabling authentication through Authentik accounts with minimal configuration. [#199](https://github.com/aura-stack-ts/auth/pull/199) - Added the `Hugging Face` OpenID Connect provider, enabling authentication through Hugging Face accounts with minimal configuration. [#198](https://github.com/aura-stack-ts/auth/pull/198) diff --git a/packages/core/src/oauth/huggingface.ts b/packages/core/src/oauth/huggingface.ts index 623526ad..c3834c76 100644 --- a/packages/core/src/oauth/huggingface.ts +++ b/packages/core/src/oauth/huggingface.ts @@ -62,4 +62,4 @@ export const huggingface = ( }) as DefaultUser, ...options, } -} \ No newline at end of file +} diff --git a/packages/core/src/oauth/instagram.ts b/packages/core/src/oauth/instagram.ts new file mode 100644 index 00000000..ddceb183 --- /dev/null +++ b/packages/core/src/oauth/instagram.ts @@ -0,0 +1,50 @@ +import type { OAuthProviderCredentials, User } from "@/@types/index.ts" + +/** + * @see [Instagram - Me Fields](https://developers.facebook.com/documentation/instagram-platform/instagram-api-with-instagram-login/get-started#fields) + */ +export interface InstagramProfile { + id: string + user_id: string + username: string + name?: string + account_type?: string + profile_picture_url?: string + followers_count?: number + follows_count?: number + media_count?: number +} + +/** + * Instagram OAuth Provider + * + * @see [Instagram - Create an App](https://developers.facebook.com/documentation/development/create-an-app) + * @see [Instagram - OAuth authorize](https://developers.facebook.com/documentation/instagram-platform/reference/oauth-authorize) + * @see [Instagram - OAuth Access Token](https://developers.facebook.com/documentation/instagram-platform/reference/access_token) + * @see [Instagram - Refresh Access Token](https://developers.facebook.com/documentation/instagram-platform/reference/refresh_access_token) + * @see [Instagram - Me Fields](https://developers.facebook.com/documentation/instagram-platform/instagram-api-with-instagram-login/get-started#fields) + */ +export const instagram = ( + options?: Partial> +): OAuthProviderCredentials => { + return { + id: "instagram", + name: "Instagram", + authorize: { + url: "https://api.instagram.com/oauth/authorize", + params: { + scope: "instagram_business_basic", + }, + }, + accessToken: "https://api.instagram.com/oauth/access_token", + userInfo: "https://graph.instagram.com/v25.0/me?fields=id,username,email,profile_picture_url", + profile: (profile) => + ({ + sub: profile.id.toString(), + name: profile.username, + email: null, + image: profile.profile_picture_url, + }) as DefaultUser, + ...options, + } +}