--- title: "跟 Sign in with Apple 的愛恨情仇" tags: "iPlayground2020" --- # 跟 Sign in with Apple 的愛恨情仇 {%hackmd vUibBZG0ToSRiPuj0wOKvg %} > 請從這裡開始 # 與 Sign in with Apple 的愛恨情仇 Johnny [投影片在此](https://speakerdeck.com/j796160836/yu-sign-in-with-apple-de-ai-hen-qing-chou-at-iplayground2020) {%speakerdeck j796160836/yu-sign-in-with-apple-de-ai-hen-qing-chou-at-iplayground2020 %} [文字版文章](https://blog.jks.coffee/sign-in-with-apple/) ## Sign in with Apple 使用 Apple ID 登入,保護隱私權 ### App 登入 點 Sign in with Apple 的按鈕後,會出現類似 Apple Pay 的介面,使用者可以選擇是否要分享自己的 Email 出去 開發者拿到資訊後,要跟 Server 檢查,成功後才通知 App ### 網站登入 用 Javascript,轉跳到蘋果的登入頁面,完成後會轉跳回去 ### 所需材料 - Client ID (App ID, Service ID) - Service ID (Domain URL need SSL) - Sign Key ### App 端實作 登入 Button: 蘋果提供了很多樣式可以直接使用 ### 網站實作 有官方按鈕產生器可以使用 ## JSON Web Token 一種格式規範,由 Header/ Payload/ Signature 組成 ### Troubleshooting(其餘請參考蘋果文件) #### invalid_request - 通常是連參數都弄錯 #### invalid_client - 可能是 client_id 弄錯 - 可能是 client_secret (JWT 格式)裡的 sub 參數跟 client_id 參數不吻合 #### invalid_grant - 可能是 client_secret (JWT格式)加解密算錯 - 可能是 Authorization Code過期 (效期通常只有1-2分鐘,不超過5分鐘) - 可能是 Authorization Code已被使用,變成無效的code (API帶相同參數重複打就會出現) ###### tags:`iPlayground2020`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up