Skip to content

Commit 2cb9976

Browse files
committed
update readme
1 parent 28e3db6 commit 2cb9976

1 file changed

Lines changed: 60 additions & 1 deletion

File tree

README.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,60 @@
1-
# TODO
1+
# TODO
2+
3+
- Documentation
4+
- Refresh Token
5+
- Auth0 Params
6+
- Clean Code
7+
8+
9+
Basic use:
10+
11+
```tsx
12+
import React from 'react';
13+
import { View, Button, Text } from 'react-native';
14+
import { useAuth, AuthProviderConfig, AuthProvider } from '@cobuildlab/react-native-auth0';
15+
import { Credentials } from 'react-native-auth0';
16+
import AsyncStorage from '@react-native-async-storage/async-storage';
17+
18+
import { auth0 } from './src/shared/auth0/client';
19+
20+
const App: React.FC = () => {
21+
const { login, logout, isLoading, isAuthenticated } = useAuth();
22+
console.log('---- isAuthenticated --- ', isAuthenticated);
23+
console.log('---- isLoading --- ', isLoading);
24+
25+
return (
26+
<View>
27+
<Text>{isAuthenticated ? 'Im On' : 'Im Off'}</Text>
28+
<Button onPress={login} title="login" />
29+
<Button onPress={logout} title="logout" />
30+
</View>
31+
);
32+
};
33+
34+
const Conifg: AuthProviderConfig = {
35+
auth0,
36+
eichBaseToken: '8base-token',
37+
eichBaseAuthProfileId: 'my-profile-id',
38+
eichBaseEndpoint: '8base-environemnt-branch',
39+
removeCredentials: async () => {
40+
await AsyncStorage.removeItem('credentials_store');
41+
},
42+
saveCredentials: async (credentials) => {
43+
const value = JSON.stringify(credentials);
44+
await AsyncStorage.setItem('credentials_store', value);
45+
},
46+
getCredentials: async (): Promise<Credentials | null> => {
47+
const value = await AsyncStorage.getItem('credentials_store');
48+
return value != null ? JSON.parse(value) : null;
49+
},
50+
};
51+
52+
export const App = () => {
53+
return (
54+
<AuthProvider config={Conifg}>
55+
<App />
56+
</AuthProvider>
57+
);
58+
};
59+
```
60+

0 commit comments

Comments
 (0)