# การยืนยันตัวตนและการจัดการเซสชัน (React Native) > OAuth2/OIDC, PKCE, refresh token, การจัดเก็บเซสชันอย่างปลอดภัย, webview เทียบกับ in-app browser, การยืนยันตัวตนด้วยไบโอเมตริก - 22 คำถามสัมภาษณ์ - Mid-Level - [คำถามสัมภาษณ์: React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions.md) ## 1. OAuth2 คืออะไรในบริบทของการยืนยันตัวตนบนมือถือ? **คำตอบ** OAuth2 เป็นโปรโตคอลการให้สิทธิ์มาตรฐานอุตสาหกรรมที่อนุญาตให้แอปพลิเคชันบนมือถือเข้าถึงทรัพยากรของผู้ใช้โดยไม่เปิดเผยข้อมูลรับรองของพวกเขา มันทำงานโดยมอบหมายการยืนยันตัวตนให้กับเซิร์ฟเวอร์การให้สิทธิ์ที่ออก access token ต่างจากการยืนยันตัวตนโดยตรงที่แอปพลิเคชันจัดการรหัสผ่าน OAuth2 อนุญาตให้ผู้ใช้ยืนยันตัวตนผ่านผู้ให้บริการบุคคลที่สาม (Google, Apple ฯลฯ) อย่างปลอดภัย ## 2. ความแตกต่างหลักระหว่าง OAuth2 และ OpenID Connect (OIDC) คืออะไร? **คำตอบ** OAuth2 เป็นโปรโตคอลการให้สิทธิ์ (authorization) ที่ช่วยให้ได้รับสิทธิ์เข้าถึงทรัพยากร ในขณะที่ OIDC เป็นชั้นข้อมูลตัวตน (identity layer) ที่สร้างขึ้นบน OAuth2 และเพิ่มการยืนยันตัวตน OIDC นำเสนอ ID token ที่มีข้อมูลเกี่ยวกับตัวตนของผู้ใช้ (claims) ในรูปแบบ JWT ทำให้แอปพลิเคชันทราบว่าผู้ใช้เป็นใคร ไม่ใช่เพียงแค่ทราบว่าผู้ใช้มีสิทธิ์เข้าถึงทรัพยากรบางอย่างเท่านั้น ## 3. PKCE (Proof Key for Code Exchange) คืออะไร และเหตุใดจึงจำเป็นสำหรับแอปพลิเคชันมือถือ? **คำตอบ** PKCE เป็นส่วนขยายด้านความปลอดภัยของ OAuth2 ที่ป้องกันการโจมตีแบบดักจับ authorization code มันทำงานโดยการสร้าง code_verifier แบบสุ่มที่ฝั่งไคลเอนต์ ซึ่งจะนำมาคำนวณเป็น code_challenge แล้วส่งไปพร้อมกับคำขอการให้สิทธิ์ เมื่อนำโค้ดไปแลกเป็น token จะส่ง code_verifier ต้นฉบับไปและเซิร์ฟเวอร์จะตรวจสอบ สิ่งนี้สำคัญอย่างยิ่งสำหรับแอปมือถือ เพราะแอปเหล่านี้ไม่สามารถเก็บ client_secret ให้เป็นความลับได้ ## มีอีก 19 คำถาม - OAuth2 flow แบบใดที่แนะนำสำหรับแอปพลิเคชันมือถือ React Native? - อะไรคือความแตกต่างระหว่าง access token และ refresh token? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ React Native อื่นๆ - [พื้นฐาน JavaScript](https://sharpskill.dev/th/technologies/react-native/interview-questions/javascript-essentials.md): 25 คำถาม, Junior - [พื้นฐาน React](https://sharpskill.dev/th/technologies/react-native/interview-questions/react-fundamentals.md): 20 คำถาม, Junior - [พื้นฐาน React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions/react-native-basics.md): 22 คำถาม, Junior - [React Hooks](https://sharpskill.dev/th/technologies/react-native/interview-questions/react-hooks.md): 20 คำถาม, Junior - [TypeScript สำหรับ React และ React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions/typescript-for-react-native.md): 22 คำถาม, Junior - [คอมโพเนนต์และ API ของ React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-components-api.md): 20 คำถาม, Junior - [การจัดสไตล์และเลย์เอาต์ใน React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-styling-layout.md): 18 คำถาม, Junior - [การนำทางใน React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-navigation.md): 22 คำถาม, Mid-Level - [การจัดการ State ใน React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-state-management.md): 24 คำถาม, Mid-Level - [Networking และ API ใน React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-networking-api.md): 20 คำถาม, Mid-Level - [การคงอยู่ของข้อมูล](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-data-persistence.md): 20 คำถาม, Mid-Level - [ฟอร์มและการตรวจสอบความถูกต้อง](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-forms-validation.md): 18 คำถาม, Mid-Level - [แอนิเมชัน React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-animations.md): 22 คำถาม, Mid-Level - [Native Modules & Bridge](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-native-modules.md): 20 คำถาม, Mid-Level - [โค้ดเฉพาะแพลตฟอร์ม](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-platform-specific-code.md): 18 คำถาม, Mid-Level - [สิทธิ์และ Device API](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-permissions-apis.md): 20 คำถาม, Mid-Level - [Push Notifications](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-push-notifications.md): 18 คำถาม, Mid-Level - [การทดสอบ React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-testing.md): 20 คำถาม, Mid-Level - [การ Debug React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-debugging.md): 18 คำถาม, Mid-Level - [Build & Deployment](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-build-deployment.md): 20 คำถาม, Mid-Level - [Expo vs React Native Bare](https://sharpskill.dev/th/technologies/react-native/interview-questions/expo-vs-bare-rn.md): 18 คำถาม, Mid-Level - [การเพิ่มประสิทธิภาพ](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-performance-optimization.md): 24 คำถาม, Senior - [การจัดการหน่วยความจำ](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-memory-management.md): 20 คำถาม, Senior - [Architecture Patterns](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-architecture-patterns.md): 22 คำถาม, Senior - [React Native New Architecture](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-new-architecture.md): 24 คำถาม, Senior - [แนวทางปฏิบัติที่ดีที่สุดด้านความปลอดภัย](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-security-best-practices.md): 20 คำถาม, Senior - [Offline-First Architecture](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-offline-first.md): 20 คำถาม, Senior - [CI/CD React Native](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-ci-cd.md): 20 คำถาม, Senior - [Monorepo และการแชร์โค้ด](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-monorepo-architecture.md): 18 คำถาม, Senior - [หัวข้อขั้นสูง](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-advanced-topics.md): 22 คำถาม, Senior - [วงจรชีวิตแอปและการทำงานเบื้องหลัง](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-app-lifecycle-background.md): 20 คำถาม, Mid-Level - [Monitoring & Crash Reporting](https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-monitoring-crash-reporting.md): 20 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/react-native/interview-questions/rn-auth-session-management