generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added deeplinking which is working fine now
- Loading branch information
1 parent
44fcd13
commit b166cf8
Showing
7 changed files
with
120 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,70 @@ | ||
const githubConfig = { | ||
clientId: '23c78f66ab7964e5ef97', | ||
// const githubConfig = { | ||
// redirectUrl: 'x-realdevsquad-rdsapp://oauth2/authorize', | ||
// clientId: '23c78f66ab7964e5ef97', | ||
// clientSecret: '65621db87076180ab274b6dbdc1a3dd95b9dd952', | ||
// scopes: ['notifications', 'user', 'identity'], | ||
// serviceConfiguration: { | ||
// authorizationEndpoint: 'https://github.com/login/oauth/authorize', | ||
// tokenEndpoint: 'https://github.com/login/oauth/access_token', | ||
// revocationEndpoint: | ||
// 'https://github.com/settings/connections/applications/969f022b19e148218c41' | ||
// }, | ||
// }; | ||
|
||
import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
|
||
export const clientId = '23c78f66ab7964e5ef97'; | ||
export const clientSecret = '65621db87076180ab274b6dbdc1a3dd95b9dd952'; | ||
export const redirectUri = 'x-realdevsquad-rdsapp://oauth2/authorize'; | ||
export const tokenUrl = 'https://github.com/login/oauth/access_token'; | ||
|
||
const githubConfig = async (authorizationCode) => { | ||
|
||
// Make POST request and handle response as previously explained | ||
console.log('response in github config', authorizationCode); | ||
|
||
const response = await fetch(tokenUrl, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Accept: 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
client_id: clientId, | ||
client_secret: clientSecret, | ||
code: authorizationCode, | ||
redirect_uri: redirectUri, | ||
}), | ||
}); | ||
console.log('response in github config', response); | ||
|
||
if (response.ok) { | ||
console.log('response is the res ok?'); | ||
|
||
const data = await response.json(); | ||
const accessToken = data.access_token; | ||
|
||
// Call a function to securely store the access token | ||
storeAccessTokenSecurely(accessToken); | ||
} else { | ||
// Handle error response | ||
console.log('error'); | ||
console.error( | ||
'Error exchanging code for access token:', | ||
response.status, | ||
response.statusText, | ||
); | ||
} | ||
}; | ||
|
||
const storeAccessTokenSecurely = async (accessToken) => { | ||
console.log('access token', accessToken); | ||
try { | ||
// Store the access token in a secure storage | ||
await AsyncStorage.setItem('access_token', accessToken); | ||
console.log('Access token stored securely.'); | ||
} catch (error) { | ||
console.error('Error storing access token:', error); | ||
} | ||
}; | ||
export { githubConfig }; |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// export const linkingConfig = { | ||
// prefix: 'rds://', | ||
// const state = { | ||
// routes: [ | ||
// { | ||
// name: 'rooms', | ||
// state: { | ||
// routes: [ | ||
// { | ||
// name: 'chat', | ||
// params: { user: 'jane' }, | ||
// }, | ||
// ], | ||
// }, | ||
// }, | ||
// ], | ||
// }; | ||
// } |
This file contains 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