mirror of
https://github.com/immich-app/immich.git
synced 2025-03-28 22:49:06 +02:00
* feat(.well-known): add .well-known/immich to reference API endpoint * feat(.well-known): make schema optional (defaults to https) * adjust method comment to be a little less confusing * fix casting issue with resovled url * include when checking Well-known, update server hint * add validation for login form's server url * consolidate common process into resolveAndSetEndpoint * fix missed prettier formatting * revert translation changes * update environment variable description, hopefully a bit clearer * rename environment variable to IMMICH_API_URL_EXTERNAL * comment out optional env variables * fix(web): browser-side api client to include authorization token * Revert "fix(web): browser-side api client to include authorization token" This reverts commit 60e338938f25792adb233d35bcecbd789bdb3240. * remove multi-domain related changes
41 lines
1.0 KiB
Dart
41 lines
1.0 KiB
Dart
import 'package:immich_mobile/shared/services/api.service.dart';
|
|
import 'package:openapi/api.dart';
|
|
import 'package:flutter_web_auth/flutter_web_auth.dart';
|
|
|
|
// Redirect URL = app.immich://
|
|
|
|
class OAuthService {
|
|
final ApiService _apiService;
|
|
final callbackUrlScheme = 'app.immich';
|
|
|
|
OAuthService(this._apiService);
|
|
|
|
Future<OAuthConfigResponseDto?> getOAuthServerConfig(
|
|
String serverUrl,
|
|
) async {
|
|
// Resolve API server endpoint from user provided serverUrl
|
|
await _apiService.resolveAndSetEndpoint(serverUrl);
|
|
|
|
return await _apiService.oAuthApi.generateConfig(
|
|
OAuthConfigDto(redirectUri: '$callbackUrlScheme:/'),
|
|
);
|
|
}
|
|
|
|
Future<LoginResponseDto?> oAuthLogin(String oauthUrl) async {
|
|
try {
|
|
var result = await FlutterWebAuth.authenticate(
|
|
url: oauthUrl,
|
|
callbackUrlScheme: callbackUrlScheme,
|
|
);
|
|
|
|
return await _apiService.oAuthApi.callback(
|
|
OAuthCallbackDto(
|
|
url: result,
|
|
),
|
|
);
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|