Small library designed for use with Expo, for getting user data from the Microsoft Graph API, using Azure AD for authentication, and following the Microsoft Azure AD auth flow. AzureADGraph is not a react component.
npm install azure-ad-graph-exponpm or yarn like so:sh
npm install azure-ad-graph-expo
`
`sh
yarn add azure-ad-graph-expo
`$3
`javascript
import React from 'react';
import { StyleSheet, View, Text, Button } from 'react-native'
import * as AuthSession from 'expo-auth-session';
import { openAuthSession } from 'azure-ad-graph-expo';export default class App extends React.Component {
state = {
result: null,
};
render() {
return (
{this.state.result ? (
{JSON.stringify(this.state.result)}
) : Nothing to see here. }
);
}
_handlePressAsync = async () => {
let result = await openAuthSession(azureAdAppProps);
this.setState({ result });
}
}
const azureAdAppProps = {
clientId : AZURE_CLIENT_ID,
tenantId : AZURE_TENANT_ID,
scope : 'user.read',
redirectUrl : AuthSession.makeRedirectUri(),
returnUrl : null, // If left as 'null', redirectUrl will be used instead
clientSecret : AZURE_CLIENT_SECRET,
domainHint : AZURE_DOMAIN_HINT,
prompt : 'login'
};
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
``