π‘ apple developers setting
π¨ μ ν κ°λ°μ λ±λ‘
https://developer.apple.com/kr/ μ μ μνμ¬ μ ν κ°λ°μ λ±λ‘μ νλ€. (μ λ£ : μ νν μκΈμ ννμ΄μ§ μ°Έκ³ )
π¨ μ± ID λ±λ‘
μλμ νλ©΄μμ μλ³μλ‘ νμΌλ‘ μ΄λ.
Identifiers μμ + λ²νΌ ν΄λ¦
Description μλ μμλ³Ό μ΄λ¦ (ex : logintest ) , Bundle ID μλ μ¬μ©ν μ± μ£Όμ ( ex : com.login.test ) μ λ ₯ ν
Capabilities μμ Sign in with Apple ν΄λ¦ ν κ³μνκΈ°.
π¨ μλΉμ€ μμ΄λ μμ± (μμ νλ¬μ€ λ²νΌ ν Service IDs)
- μμ±ν ν ν΄λ¦ν΄μ μ μνλ©΄ μλμ 체ν¬λ°μ€μ configure λ²νΌμ΄ λνλλ€. 체ν¬νκ³ λ²νΌ ν΄λ¦
- μμ±νλ apple idμ return urlsμ λ‘κ·ΈμΈμλ£ ν λ°νν url μ λ£λλ€
π¨ ν€ μμ±
- Keys μ + λ²νΌ ν΄λ¦
- key μ΄λ¦κ³Ό sign in with apple μ ν΄λ¦ ν μ μ₯
- key idμ key file μ΄ λ°κΈλλλ° idλ ννμ΄μ§μμ λ€μ λ³Ό μ μμ§λ§ fileμ μ²μ ν λ²λ°μ λ°κΈμ΄ μλλ λΆμ€ μ‘°μ¬.
π΄ config.json μμ±
- κΈ°λ³Έν
{
"client_id": "",
"team_id": "",
"redirect_uri": "",
"key_id": "",
"scope": ""
}
μμ κ°κ°μ κ°λ€ μ°Έμ‘°λ μλ λ§ν¬
https://github.com/ananay/apple-auth/blob/master/SETUP.md
π μμ€ κ΅¬ν
1. λ‘κ·ΈμΈ νμ΄μ§λ‘ μ΄λ λΌμ°ν° ꡬν
import AppleAuth from 'apple-auth';
import fs from 'fs';
const config = fs.readFileSync('./config/iosconfig.json');
let auth = new AppleAuth(config, fs.readFileSync('./config/AuthKey_Y2WQX8897P.p8').toString(), 'text');
const router = Router();
router.get('/', (req, res) => {
console.log(Date().toString() + 'GET /');
res.send(`<a href="${auth.loginURL()}">Sign in with Apple</a>`);
});
π€ Reference
https://github.com/ananay/apple-auth/blob/master/SETUP.md
https://github.com/ananay/apple-auth-example/blob/master/src/app.js