ํฐ์คํ ๋ฆฌ ๋ทฐ
๋ฐ์ํ
๐ Apple OAuth Provider ๊ฐ์
Apple OAuth๋ OAuth 2.0 ๋ฐ OpenID Connect๋ฅผ ์ง์ํ๋ฉฐ,
Apple ID๋ฅผ ํตํด ๊ฐํธํ๊ฒ ์ธ์ฆํ ์ ์๋ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค.
๐ ๏ธ ์ค์ ์์ (pages/api/auth/[...nextauth].ts)
import NextAuth from "next-auth"
import AppleProvider from "next-auth/providers/apple"
export default NextAuth({
providers: [
AppleProvider({
clientId: process.env.APPLE_CLIENT_ID,
clientSecret: process.env.APPLE_CLIENT_SECRET,
}),
],
})
๐ ํ๊ฒฝ ๋ณ์ ์ค์ (.env)
APPLE_CLIENT_ID=com.example.app
APPLE_CLIENT_SECRET=your-apple-client-secret
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-nextauth-secret
๐ Apple Developer ๊ณ์ ์ค์
- Apple Developer ๊ณ์ ์ ๋ก๊ทธ์ธ
- Identifiers → Services IDs → ์๋ก์ด ์๋น์ค ID ์์ฑ
- Redirect URI:
- https://localhost:3000/api/auth/callback/apple
- Key ์์ฑ:
- Apple ํค ID๋ฅผ ๋ฐ๊ธ๋ฐ์์ผ ํจ
- ํ ID๋ ํ์
๐ Apple Private Key ์์ฑ
๋ฐ์ํ
- Apple Developer Console์์ ํค ์์ฑ
- ์์ฑ๋ .p8 ํค ํ์ผ์ ํ๋ก์ ํธ์ ์ถ๊ฐ
- ํ๊ฒฝ ๋ณ์ ์ค์ :
- APPLE_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\nMIIEv...\n-----END PRIVATE KEY-----" APPLE_KEY_ID=ABC123DEFG APPLE_TEAM_ID=TEAM123456
๐ Apple ํด๋ผ์ด์ธํธ ์ํฌ๋ฆฟ ์์ฑ ํจ์
Apple OAuth์์๋ JWT ํ ํฐ์ ํด๋ผ์ด์ธํธ ์ํฌ๋ฆฟ์ผ๋ก ์ฌ์ฉํฉ๋๋ค.
๋ค์๊ณผ ๊ฐ์ ์ ํธ๋ฆฌํฐ ํจ์๋ฅผ ์ฌ์ฉํ์ฌ JWT๋ฅผ ์์ฑํฉ๋๋ค:
import jwt from "jsonwebtoken"
function generateAppleSecret() {
return jwt.sign(
{
iss: process.env.APPLE_TEAM_ID,
aud: "https://appleid.apple.com",
sub: process.env.APPLE_CLIENT_ID,
},
process.env.APPLE_PRIVATE_KEY.replace(/\\n/g, '\n'),
{
algorithm: "ES256",
expiresIn: "1h",
keyid: process.env.APPLE_KEY_ID,
}
)
}
๐ Apple OAuth ์ฝ๋ฐฑ ์ค์
async function jwt({ token, account }) {
if (account?.provider === "apple") {
token.idToken = account.id_token
}
return token
}
โ ๏ธ ์ฃผ์์ฌํญ
- Apple OAuth๋ ๋น๋ฐ๋ฒํธ ๋์ ์์ฒด ์ธ์(Face ID/Touch ID)์ ์ง์ํฉ๋๋ค.
- id_token์ ์ฌ์ฉํด ์ฌ์ฉ์์ ์ด๋ฆ๊ณผ ์ด๋ฉ์ผ์ ๊ฐ์ ธ์์ผ ํฉ๋๋ค.
์ด๊ธฐ ๋ก๊ทธ์ธ ์ ํ ๋ฒ๋ง ์ ๊ณต๋๋ฏ๋ก ๋ฐ๋์ ์ ์ฅํด๋์ธ์.
NextAuth Apple OAuth, Apple ๋ก๊ทธ์ธ ๊ตฌํ, OAuth2 Next.js, Apple ID ์ธ์ฆ ์ค์ , Apple Private Key ์ฌ์ฉ๋ฒ, JWT ํ ํฐ ์์ฑ, OAuth ์ฝ๋ฐฑ ์ฒ๋ฆฌ, Next.js ๋ก๊ทธ์ธ ๊ตฌ์ฑ, Apple ํค ์ค์ , SEO ์ต์ ํ 10๊ฐ
'framework > NextAuth' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ Auth0 OAuth Provider ๊ฐ์ (0) | 2025.05.12 |
---|---|
๐ ๏ธ Atlassian OAuth Provider ๊ฐ์ (0) | 2025.05.09 |
โ 42 School OAuth Provider ๊ฐ์ (0) | 2025.05.07 |
โ Next.js์์ NextAuth.js ํตํฉ ์ค์ ๊ฐ์ด๋ ์์ฝ (0) | 2025.04.30 |
โ NextAuth.js ์ด๋ฒคํธ(Events) ์ค์ (0) | 2025.04.29 |
โป ์ด ํฌ์คํ
์ ์ฟ ํก ํํธ๋์ค ํ๋์ ์ผํ์ผ๋ก, ์ด์ ๋ฐ๋ฅธ ์ผ์ ์ก์ ์์๋ฃ๋ฅผ ์ ๊ณต๋ฐ์ต๋๋ค.
๊ณต์ง์ฌํญ
์ต๊ทผ์ ์ฌ๋ผ์จ ๊ธ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
- Total
- Today
- Yesterday
๋งํฌ
TAG
- seo ์ต์ ํ 10๊ฐ
- REACT
- SEO ์ต์ ํ
- CI/CD
- ํ์ด์ฌ์๊ณ ๋ฆฌ์ฆ
- llm
- ํ๋ก ํธ์๋๋ฉด์
- ์น๊ฐ๋ฐ
- PostgreSQL
- kotlin
- ๊ฐ๋ฐ๋ธ๋ก๊ทธ
- flax
- rag
- NestJS
- App Router
- SEO์ต์ ํ
- fastapi
- Prisma
- gatsbyjs
- AI์ฑ๋ด
- Python
- Docker
- nodejs
- ๋ฐฑ์๋๊ฐ๋ฐ
- ํ๋ก ํธ์๋
- Ktor
- ๋ฅ๋ฌ๋
- Next.js
- JAX
- nextJS
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
๊ธ ๋ณด๊ดํจ
๋ฐ์ํ