-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
84 lines (75 loc) · 2.17 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* Generated with the TypeScript template
* https://github.com/react-native-community/react-native-template-typescript
*
* @format
*/
import React, {useState} from 'react';
import {
SafeAreaView,
Button,
Alert,
UIManager,
LayoutAnimation,
Platform,
} from 'react-native';
import {authorize, refresh, revoke} from 'react-native-app-auth';
UIManager.setLayoutAnimationEnabledExperimental &&
UIManager.setLayoutAnimationEnabledExperimental(true);
type State = {
hasLoggedInOnce: boolean;
accessToken: string | null;
accessTokenExpirationDate: string | null;
refreshToken: string | null;
};
const config = {
issuer:
'https://ksg1806.b2clogin.com/22c7745c-fd5a-4214-ba7a-bc07bf05684b/v2.0/',
clientId: '43e96235-af0e-480b-9b93-8f6d28dca287',
redirectUrl: 'com.demo.azureb2c://callback/',
additionalParameters: {},
scopes: ['openid', 'offline_access'],
serviceConfiguration: {
authorizationEndpoint:
'https://ksg1806.b2clogin.com/ksg1806.onmicrosoft.com/b2c_1_signup_signin/oauth2/v2.0/authorize',
tokenEndpoint:
'https://ksg1806.b2clogin.com/ksg1806.onmicrosoft.com/b2c_1_signup_signin/oauth2/v2.0/token',
revocationEndpoint:
'https://ksg1806.b2clogin.com/ksg1806.onmicrosoft.com/b2c_1_signup_signin/oauth2/v2.0/logout',
},
};
const App = () => {
const [state, setState] = useState({
hasLoggedInOnce: false,
accessToken: '',
accessTokenExpirationDate: '',
refreshToken: '',
});
const onauthorize = async () => {
try {
const result = await authorize(config);
// this.animateState(
// {
// hasLoggedInOnce: true,
// accessToken: authState.accessToken,
// accessTokenExpirationDate: authState.accessTokenExpirationDate,
// refreshToken: authState.refreshToken
// },
// 500
// );
// console.log('hello');
console.log(result);
} catch (error: any) {
Alert.alert('Failed to log in', error.message);
}
};
return (
<SafeAreaView>
<Button title="Sign In" onPress={onauthorize} />
</SafeAreaView>
);
};
export default App;