diff --git a/docs/media/authentication_guide.md b/docs/media/authentication_guide.md index 381967d4efc..8ee45065c94 100644 --- a/docs/media/authentication_guide.md +++ b/docs/media/authentication_guide.md @@ -316,6 +316,45 @@ return ( ) ``` + +For React Native, you can use `Auth.federatedSignIn()` to get your federated identity from Cognito. You need to provide a valid JWT token from the third provider. You can also use it with `Authenticator` so that your login status will be automatically persisted by that component. + +Federated Sign in with Facebook Example: +```js +import Expo from 'expo'; +import Amplify, { Auth } from 'aws-amplify'; +import { Authenticator } from 'aws-amplify-react-native'; + +export default class App extends React.Component { + async signIn() { + const { type, token, expires } = await Expo.Facebook.logInWithReadPermissionsAsync('YOUR_FACEBOOK_APP_ID', { + permissions: ['public_profile'], + }); + if (type === 'success') { + // sign in with federated identity + Auth.federatedSignIn('facebook', { token, expires_at: expires}, { name: 'USER_NAME' }) + .then(credentials => { + console.log('get aws credentials', credentials); + }).catch(e => { + console.log(e); + }); + } + } + + // ... + + render() { + return ( + + + +