diff --git a/docs/pages/versions/unversioned/sdk/app-auth.md b/docs/pages/versions/unversioned/sdk/app-auth.md index e94525db6785f..2e56b567bed94 100644 --- a/docs/pages/versions/unversioned/sdk/app-auth.md +++ b/docs/pages/versions/unversioned/sdk/app-auth.md @@ -3,10 +3,17 @@ title: AppAuth sourceCodeUrl: 'https://github.com/expo/expo/tree/sdk-36/packages/expo-app-auth' --- +import SnackInline from '~/components/plugins/SnackInline'; import TableOfContentSection from '~/components/plugins/TableOfContentSection'; **`expo-app-auth`** allows you to authenticate and authorize your users through the native OAuth library AppAuth by [OpenID](https://github.com/openid). +Many services that let you authenticate with them or login with them, like GitHub, Google, GitLab, etc., use the OAuth 2.0 protocol. It's the industry standard. + +If you are trying to implement sign in with [Google](../google-sign-in) or [Facebook](../facebook), there are special modules in the Expo SDK for those (though this module will work). + +Currently, this module only supports on Android, and iOS. Web support is planned to be added. Track it here: [Web support in expo-app-auth](https://github.com/expo/expo/issues/6883). + #### Platform Compatibility | Android Device | Android Emulator | iOS Device | iOS Simulator | Web | @@ -19,59 +26,84 @@ For [managed](../../introduction/managed-vs-bare/#managed-workflow) apps, you'll ## Usage -Below is a set of example functions that demonstrate how to use `expo-app-auth` with the Google OAuth Sign-In provider. + Below is a set of example functions that demonstrate how to use `expo-app-auth` with the Google OAuth sign in provider. -```js -import { AsyncStorage } from 'react-native'; + + +```tsx +import React, { useEffect, useState } from 'react'; +import { AsyncStorage, Button, StyleSheet, Text, View } from 'react-native'; import * as AppAuth from 'expo-app-auth'; -const config = { +export default function App() { + let [authState, setAuthState] = useState(null); + + useEffect(() => { + (async () => { + let cachedAuth = await getCachedAuthAsync(); + if (cachedAuth && !authState) { + setAuthState(cachedAuth); + } + })(); + }, []); + + return ( + + Expo AppAuth Example +