refactor app configuration and improve Google OAuth handling; update .gitignore and enhance test documentation

This commit is contained in:
bobbert committed 2026-02-22 22:35:57 +00:00
1 parent cb74405f5f
commit d865708e28
6 files changed
+79 -41

No files matched your search

+10 -10
View File
@@ -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) {
+5 -5
View File
@@ -199,13 +199,13 @@ const styles = StyleSheet.create({
centerContainer: { flex: 1, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 24 },
loadingText: { marginTop: 12, fontSize: 14 },
// Filter chips
filterRow: { paddingHorizontal: 12, paddingVertical: 8, gap: 8 },
filterRow: { paddingHorizontal: 12, paddingVertical: 6, gap: 6 },
chip: {
flexDirection: 'row', alignItems: 'center', paddingHorizontal: 14, paddingVertical: 7,
borderRadius: 20, gap: 6,
flexDirection: 'row', alignItems: 'center', paddingHorizontal: 10, paddingVertical: 4,
borderRadius: 12, gap: 4,
},
chipIcon: { fontSize: 13 },
chipText: { fontSize: 13, fontWeight: '500', color: '#3c4043' },
chipIcon: { fontSize: 11 },
chipText: { fontSize: 12, fontWeight: '500', color: '#3c4043' },
// Empty
emptyTitle: { fontSize: 18, fontWeight: '600', marginBottom: 6 },
emptyText: { fontSize: 13, textAlign: 'center', marginBottom: 20 },