import { Callout } from "nextra/components"
import { Code } from "@/components/Code"

<img align="right" src="/img/providers/instagram.svg" height="64" width="64" />

# Instagram Provider

## Resources

- [Instagram OAuth documentation](https://developers.facebook.com/docs/instagram-basic-display-api/getting-started)
- [Instagram OAuth apps](https://developers.facebook.com/apps/)

## Setup

### Callback URL

<Code>
  <Code.Next>

```bash
https://example.com/api/auth/callback/instagram
```

  </Code.Next>
  <Code.Qwik>

```bash
https://example.com/auth/callback/instagram
```

  </Code.Qwik>
  <Code.Svelte>

```bash
https://example.com/auth/callback/instagram
```

  </Code.Svelte>
</Code>

### Environment Variables

```
AUTH_INSTAGRAM_ID
AUTH_INSTAGRAM_SECRET
```

### Configuration

<Code>
  <Code.Next>

```ts filename="/auth.ts"
import NextAuth from "next-auth"
import Instagram from "next-auth/providers/instagram"

export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [Instagram],
})
```

  </Code.Next>
  <Code.Qwik>
  
```ts filename="/src/routes/plugin@auth.ts"
import { QwikAuth$ } from "@auth/qwik"
import Instagram from "@auth/qwik/providers/instagram"

export const { onRequest, useSession, useSignIn, useSignOut } = QwikAuth$(
  () => ({
    providers: [Instagram],
  })
)
```

  </Code.Qwik>
  <Code.Svelte>

```ts filename="/src/auth.ts"
import { SvelteKitAuth } from "@auth/sveltekit"
import Instagram from "@auth/sveltekit/providers/instagram"

export const { handle, signIn, signOut } = SvelteKitAuth({
  providers: [Instagram],
})
```

  </Code.Svelte>
  <Code.Express>

```ts filename="/src/app.ts"
import { ExpressAuth } from "@auth/express"
import Instagram from "@auth/express/providers/instagram"

app.use("/auth/*", ExpressAuth({ providers: [Instagram] }))
```

  </Code.Express>
</Code>

### Notes

- Email address is not returned by the Instagram API.
- Instagram requires a callback URL to be configured in your Facebook app and Facebook requires you to use **https** even for localhost. In order to do that, you either need to [add an SSL to your localhost](https://www.freecodecamp.org/news/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec/) or use a proxy such as [ngrok](https://ngrok.com/docs).
