data/services/oauth_service library

Classes

AccountInfo
Account info persisted in global config.
AuthCodeListener
Temporary localhost HTTP server that listens for OAuth authorization code redirects.
OAuthConfig
OAuth configuration URLs and client IDs.
OAuthProfileAccount
Account details in the profile response.
OAuthProfileOrganization
Organization details in the profile response.
OAuthProfileResponse
Profile response from the OAuth profile endpoint.
OAuthService
OAuth service that handles the OAuth 2.0 authorization code flow with PKCE.
OAuthTokenAccount
Account info from token exchange.
OAuthTokenAccountInfo
Account info stored alongside tokens.
OAuthTokenExchangeResponse
OAuth token exchange response from the token endpoint.
OAuthTokenOrganization
Organization info from token exchange.
OAuthTokens
Full OAuth tokens (client-side representation).
RateLimitTier
Rate limit tier information.
UserRolesResponse
User roles response from the roles endpoint.

Enums

BillingType
Billing type for OAuth accounts.
SubscriptionType
Subscription type for OAuth accounts.

Constants

allOAuthScopes → const List<String>
All OAuth scopes.
neomageAiInferenceScope → const String
Neomage AI inference scope.
neomageAiOAuthScopes → const List<String>
Neomage AI OAuth scopes.

Functions

buildAuthUrl({required String codeChallenge, required String state, required int port, required bool isManual, bool loginWithNeomageAi = false, bool inferenceOnly = false, String? orgUUID, String? loginHint, String? loginMethod}) String
Build the OAuth authorization URL.
createApiKey({required String accessToken, HttpClient? httpClient}) Future<String?>
Create and store an API key.
exchangeCodeForTokens({required String authorizationCode, required String state, required String codeVerifier, required int port, bool useManualRedirect = false, int? expiresIn, HttpClient? httpClient}) Future<OAuthTokenExchangeResponse>
Exchange authorization code for tokens.
fetchOAuthProfile({required String accessToken, HttpClient? httpClient}) Future<OAuthProfileResponse?>
Fetch profile info from the OAuth profile endpoint.
fetchProfileInfo({required String accessToken, HttpClient? httpClient}) Future<({String? accountCreatedAt, String? billingType, String? displayName, bool? hasExtraUsageEnabled, RateLimitTier? rateLimitTier, OAuthProfileResponse? rawProfile, String? subscriptionCreatedAt, SubscriptionType? subscriptionType})?>
Fetch profile info and extract subscription details.
fetchUserRoles({required String accessToken, HttpClient? httpClient}) Future<UserRolesResponse>
Fetch and store user roles.
generateCodeChallenge(String codeVerifier) String
Generate the code challenge from the verifier (S256).
generateCodeVerifier() String
Generate a random code verifier for PKCE.
generateState() String
Generate a random state parameter for CSRF protection.
getOauthConfig() OAuthConfig
isOAuthTokenExpired(int? expiresAt) bool
Check if an OAuth token is expired (with 5 minute buffer).
parseScopes(String? scopeString) List<String>
Parse a space-separated scope string into a list.
refreshOAuthToken({required String refreshToken, List<String>? requestedScopes, HttpClient? httpClient}) Future<OAuthTokens>
Refresh an OAuth token.
setOauthConfig(OAuthConfig config) → void
shouldUseNeomageAIAuth(List<String>? scopes) bool
Check if the user has Neomage.ai authentication scope.
subscriptionTypeFromOrgType(String? orgType) SubscriptionType?
Determine subscription type from organization type string.