mirror of
https://github.com/mudabbir-ahmad/Media-Aggregation-and-Sorting-System.git
synced 2026-10-08 03:40:20 +00:00
refactor app configuration and improve Google OAuth handling; update .gitignore and enhance test documentation
This commit is contained in:
1 parent
cb74405f5f
commit
d865708e28
6 files changed
+79
-41
No files matched your search
+10
-10
@@ -4,16 +4,20 @@ import { AuthServiceBase } from './AuthServiceBase';
|
||||
|
||||
WebBrowser.maybeCompleteAuthSession();
|
||||
|
||||
// Replace with your real Google Cloud OAuth Client ID (see ignorefiles/GOOGLE_OAUTH_SETUP.md)
|
||||
const GOOGLE_CLIENT_ID = '313090284964-rgq1u7np6ogucu9o97s134n5nc6nj7kf.apps.googleusercontent.com';
|
||||
|
||||
// makeRedirectUri uses the scheme from app.json ("media-aggregation") to build
|
||||
// the deep link URI that Android will route back into the app after OAuth.
|
||||
// The resulting URI is: media-aggregation:// (registered in Google Cloud Console)
|
||||
// For Expo Go dev testing the loopback http://localhost is used instead.
|
||||
const REDIRECT_URI = AuthSession.makeRedirectUri({ scheme: 'media-aggregation' });
|
||||
|
||||
const GOOGLE_DISCOVERY = {
|
||||
authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth',
|
||||
tokenEndpoint: 'https://oauth2.googleapis.com/token',
|
||||
revocationEndpoint: 'https://oauth2.googleapis.com/revoke',
|
||||
};
|
||||
|
||||
// Google Photos Library API scopes — read, write, and user profile
|
||||
const SCOPES = [
|
||||
'https://www.googleapis.com/auth/photoslibrary',
|
||||
'https://www.googleapis.com/auth/photoslibrary.appendonly',
|
||||
@@ -48,15 +52,12 @@ class GoogleAUTH extends AuthServiceBase {
|
||||
};
|
||||
}
|
||||
|
||||
const redirectUri = AuthSession.makeRedirectUri({
|
||||
scheme: 'media-aggregation',
|
||||
preferLocalhost: true,
|
||||
});
|
||||
console.log('OAuth redirect URI:', REDIRECT_URI);
|
||||
|
||||
const authRequest = new AuthSession.AuthRequest({
|
||||
clientId: GOOGLE_CLIENT_ID,
|
||||
scopes: SCOPES,
|
||||
redirectUri,
|
||||
redirectUri: REDIRECT_URI,
|
||||
responseType: AuthSession.ResponseType.Code,
|
||||
usePKCE: true,
|
||||
extraParams: { access_type: 'offline', prompt: 'consent' },
|
||||
@@ -72,7 +73,7 @@ class GoogleAUTH extends AuthServiceBase {
|
||||
{
|
||||
clientId: GOOGLE_CLIENT_ID,
|
||||
code: result.params.code,
|
||||
redirectUri,
|
||||
redirectUri: REDIRECT_URI,
|
||||
extraParams: { code_verifier: authRequest.codeVerifier },
|
||||
},
|
||||
GOOGLE_DISCOVERY
|
||||
@@ -80,7 +81,6 @@ class GoogleAUTH extends AuthServiceBase {
|
||||
|
||||
this.accessToken = tokenResponse.accessToken;
|
||||
this.refreshToken = tokenResponse.refreshToken;
|
||||
this.idToken = tokenResponse.idToken;
|
||||
this.expiresAt = tokenResponse.issuedAt
|
||||
? (tokenResponse.issuedAt + (tokenResponse.expiresIn || 3600)) * 1000
|
||||
: Date.now() + 3600000;
|
||||
@@ -91,7 +91,7 @@ class GoogleAUTH extends AuthServiceBase {
|
||||
return {
|
||||
success: true,
|
||||
accessToken: this.accessToken,
|
||||
refreshToken: this.refreshToken,
|
||||
refreshToken: null,
|
||||
email: this.email,
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user