Last active
November 21, 2016 04:24
-
-
Save mebinum/7aa047d23919299231c52ebfb7d528dd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//import the component into your project | |
import {AzureInstance, AzureLoginView} from 'react-native-azure-ad-2' | |
//create an AzureInstance object with your Microsoft Azure credentials | |
var credentials = { | |
client_id: 'xxxxxxxx', | |
client_secret: 'xxxxxx', | |
scope: 'User.ReadBasic.All Mail.Read offline_access' //access scope for login - see http://bit.ly/2gtQe9W for more info | |
}; | |
//create a component for Azure Authentication | |
export default class azureAuth extends React.Component { | |
constructor(props){ | |
super(props); | |
//instantiate azure objects with your azure credentials | |
this.azureInstance = new AzureInstance(credentials); | |
//bind the login success function | |
this._onLoginSuccess = this._onLoginSuccess.bind(this); | |
} | |
// function to be called after login is successful | |
_onLoginSuccess(){ | |
this.azureInstance.getUserInfo().then(result => { | |
console.log(result); | |
}).catch(err => { | |
console.log(err); | |
}) | |
} | |
// pass the azureInstance and Login Success function to the AzureLoginView that will display | |
// the authentication screen | |
render() { | |
return ( | |
<AzureLoginView | |
azureInstance={this.azureInstance} | |
loadingMessage="Requesting access token" | |
onSuccess={this._onLoginSuccess} | |
/> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment