Skip to content

Commit e15802c

Browse files
Merge pull request #33 from thisyahlen-deriv/thisyahlen/update-readme
docs: update readme
2 parents 8368092 + 9f41db2 commit e15802c

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,41 @@ In this phase, we use OAuth2 with Hydra for authentication.
5050

5151
### Using the OAuth2 Provider
5252

53-
Wrap your application with the `OAuth2Provider` and use the `useOAuth` hook within your components.
53+
Use the `useOAuth2` hook within your components.
5454

5555
```typescript
5656
// src/App.tsx
5757
import React from 'react';
58-
import { OAuth2Provider } from './context/auth-context';
59-
import useOAuth from './hooks/useOAuth';
60-
import { useAuthData } from '@deriv-com/api-hooks';
58+
import { useOAuth2 } from '@deriv-com/auth-client';
6159
62-
const App: React.FC = () => {
63-
const { logout } = useAuthData();
64-
const oauthUrl = 'https://your-oauth-url.com';
60+
const YourComponent = () => {
61+
const [OAuth2EnabledApps, OAuth2EnabledAppsInitialised] = useGrowthbookGetFeatureValue<hydraBEApps>({
62+
featureFlag: 'hydra_be',
63+
});
6564
66-
return (
67-
<OAuth2Provider logout={logout} oauthUrl={oauthUrl}>
68-
<YourComponent />
69-
</OAuth2Provider>
70-
);
71-
};
65+
const { logout } = useAuthData(); // Your custom hook or function to handle logout
7266
73-
const YourComponent: React.FC = () => {
74-
const { oAuth2Logout } = useOAuth();
67+
const OAuth2GrowthBookConfig = {
68+
OAuth2EnabledApps,
69+
OAuth2EnabledAppsInitialised
70+
};
71+
72+
const WSLogoutAndRedirect = async () => {
73+
await logout();
74+
// Redirect or perform any additional actions here
75+
};
76+
77+
const { OAuth2Logout } = useOAuth2(OAuth2GrowthBookConfig, WSLogoutAndRedirect);
7578
7679
return (
7780
<div>
78-
<button onClick={oAuth2Logout}>Logout</button>
81+
<button onClick={OAuth2Logout}>Logout</button>
7982
</div>
8083
);
8184
};
8285
83-
export default App;
86+
export default YourComponent;
87+
8488
```
8589
8690
## Phase 2: OIDC Public Client

0 commit comments

Comments
 (0)