mirror of
https://github.com/mudabbir-ahmad/Media-Aggregation-and-Sorting-System.git
synced 2026-10-08 03:40:20 +00:00
added NAS configuration file; updated MediaViewer to support thumbnail carousel; improved error handling in NASAPI and NASAUTH; refactored various comments for clarity
This commit is contained in:
1 parent
9519b32d68
commit
f8e11fc368
27 files changed
+1036
-558
No files matched your search
+12
-19
@@ -4,7 +4,7 @@ import { AuthServiceBase } from './AuthServiceBase';
|
||||
|
||||
WebBrowser.maybeCompleteAuthSession();
|
||||
|
||||
// TODO: Replace with your real Google Cloud OAuth Client ID
|
||||
// Replace with your real Google Cloud OAuth Client ID (see ignorefiles/GOOGLE_OAUTH_SETUP.md)
|
||||
const GOOGLE_CLIENT_ID = 'YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com';
|
||||
|
||||
const GOOGLE_DISCOVERY = {
|
||||
@@ -13,7 +13,7 @@ const GOOGLE_DISCOVERY = {
|
||||
revocationEndpoint: 'https://oauth2.googleapis.com/revoke',
|
||||
};
|
||||
|
||||
// Google Photos Library API scopes - read and write
|
||||
// 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',
|
||||
@@ -31,19 +31,15 @@ class GoogleAUTH extends AuthServiceBase {
|
||||
this.idToken = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate with Google using expo-auth-session
|
||||
* Falls back to placeholder tokens when no real client ID is set
|
||||
*/
|
||||
// Authenticate via Google OAuth; uses placeholder tokens when no real client ID is configured
|
||||
async authenticate() {
|
||||
try {
|
||||
if (GOOGLE_CLIENT_ID === 'YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com') {
|
||||
console.log('Google Auth: Using placeholder mode (no client ID configured)');
|
||||
console.log('Google Auth: placeholder mode (no client ID configured)');
|
||||
this.accessToken = 'placeholder_google_token_' + Date.now();
|
||||
this.refreshToken = 'placeholder_refresh_' + Date.now();
|
||||
this.expiresAt = Date.now() + 3600000;
|
||||
this.email = 'google-user@placeholder.com';
|
||||
|
||||
return {
|
||||
success: true,
|
||||
accessToken: this.accessToken,
|
||||
@@ -52,8 +48,10 @@ class GoogleAUTH extends AuthServiceBase {
|
||||
};
|
||||
}
|
||||
|
||||
// Real OAuth flow
|
||||
const redirectUri = AuthSession.makeRedirectUri({ preferLocalhost: true });
|
||||
const redirectUri = AuthSession.makeRedirectUri({
|
||||
scheme: 'media-aggregation',
|
||||
preferLocalhost: true,
|
||||
});
|
||||
|
||||
const authRequest = new AuthSession.AuthRequest({
|
||||
clientId: GOOGLE_CLIENT_ID,
|
||||
@@ -114,6 +112,7 @@ class GoogleAUTH extends AuthServiceBase {
|
||||
}
|
||||
}
|
||||
|
||||
// Return a valid access token, refreshing if expired
|
||||
async getAccessToken() {
|
||||
if (this.accessToken && this.expiresAt > Date.now()) return this.accessToken;
|
||||
if (this.refreshToken) return await this.refreshAccessToken();
|
||||
@@ -165,9 +164,7 @@ class GoogleAUTH extends AuthServiceBase {
|
||||
return info || { id: 'google_user', email: this.email || 'unknown', name: 'Google User' };
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch media items from Google Photos Library API
|
||||
*/
|
||||
// Fetch media items from the Google Photos Library API
|
||||
async getPhotos(pageSize = 50, pageToken = null) {
|
||||
try {
|
||||
const token = await this.getAccessToken();
|
||||
@@ -204,9 +201,7 @@ class GoogleAUTH extends AuthServiceBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch albums from Google Photos Library API
|
||||
*/
|
||||
// Fetch album list from the Google Photos Library API
|
||||
async getAlbums(pageSize = 50, pageToken = null) {
|
||||
try {
|
||||
const token = await this.getAccessToken();
|
||||
@@ -227,9 +222,7 @@ class GoogleAUTH extends AuthServiceBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload media to Google Photos Library
|
||||
*/
|
||||
// Upload a photo to Google Photos Library
|
||||
async uploadPhoto(filePath, filename, mimeType = 'image/jpeg') {
|
||||
try {
|
||||
const token = await this.getAccessToken();
|
||||
|
||||
Reference in new issue
Block a user