### Initialize FlutterAppAuth Source: https://pub.dev/documentation/flutter_appauth/latest/index.html Create an instance of the FlutterAppAuth plugin to begin. No specific setup is required before this step. ```dart FlutterAppAuth appAuth = FlutterAppAuth(); ``` -------------------------------- ### TokenResponse Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/TokenResponse/TokenResponse.html Initializes a new instance of the TokenResponse class with the provided token details. ```APIDOC ## TokenResponse Constructor ### Description Constructs a TokenResponse object with the following parameters: ### Parameters * **accessToken** (String?) - The access token string. * **refreshToken** (String?) - The refresh token string. * **accessTokenExpirationDateTime** (DateTime?) - The expiration date and time of the access token. * **idToken** (String?) - The ID token string. * **tokenType** (String?) - The type of the token (e.g., 'Bearer'). * **scopes** (List?) - A list of scopes granted with the token. * **tokenAdditionalParameters** (Map?) - A map containing any additional parameters returned with the token response. ### Implementation ```dart TokenResponse( this.accessToken, this.refreshToken, this.accessTokenExpirationDateTime, this.idToken, this.tokenType, this.scopes, this.tokenAdditionalParameters, ); ``` ``` -------------------------------- ### accessTokenExpirationDateTime Declaration Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/TokenResponse/accessTokenExpirationDateTime.html This property indicates when the access token will expire. Applications should use the refresh token to get a new access token before it expires. ```dart final DateTime? accessTokenExpirationDateTime; ``` -------------------------------- ### TokenRequest Constructor Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/TokenRequest/TokenRequest.html The implementation of the TokenRequest constructor, initializing instance variables and calling assertConfigurationInfo(). ```dart TokenRequest( String clientId, String redirectUrl, { this.clientSecret, List? scopes, String? issuer, String? discoveryUrl, AuthorizationServiceConfiguration? serviceConfiguration, Map? additionalParameters, String? nonce, this.refreshToken, this.grantType, this.authorizationCode, this.codeVerifier, bool allowInsecureConnections = false, }) { this.clientId = clientId; this.redirectUrl = redirectUrl; this.scopes = scopes; this.serviceConfiguration = serviceConfiguration; this.additionalParameters = additionalParameters; this.nonce = nonce; this.issuer = issuer; this.discoveryUrl = discoveryUrl; this.allowInsecureConnections = allowInsecureConnections; assertConfigurationInfo(); } ``` -------------------------------- ### AuthorizationServiceConfiguration Constructor Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationServiceConfiguration/AuthorizationServiceConfiguration.html Provides the implementation details for the AuthorizationServiceConfiguration constructor, initializing its properties. ```dart const AuthorizationServiceConfiguration({ required this.authorizationEndpoint, required this.tokenEndpoint, this.endSessionEndpoint, }); ``` -------------------------------- ### AuthorizationTokenResponse Constructor Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationTokenResponse/AuthorizationTokenResponse.html Shows the implementation of the AuthorizationTokenResponse constructor, including superclass initialization. ```dart AuthorizationTokenResponse( String? accessToken, String? refreshToken, DateTime? accessTokenExpirationDateTime, String? idToken, String? tokenType, List? scopes, this.authorizationAdditionalParameters, Map? tokenAdditionalParameters, ) : super(accessToken, refreshToken, accessTokenExpirationDateTime, idToken, tokenType, scopes, tokenAdditionalParameters); ``` -------------------------------- ### TokenResponse Constructor Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/TokenResponse/TokenResponse.html This code shows the implementation of the TokenResponse constructor, which initializes the object with various token-related properties. ```dart TokenResponse( this.accessToken, this.refreshToken, this.accessTokenExpirationDateTime, this.idToken, this.tokenType, this.scopes, this.tokenAdditionalParameters, ); ``` -------------------------------- ### FlutterAppAuth() Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuth-class.html Constructs a new FlutterAppAuth instance. ```APIDOC ## Constructors ### FlutterAppAuth() **Description**: Creates a new instance of the FlutterAppAuth class. **Usage**: Instantiate the class to begin making authorization or token requests. ``` -------------------------------- ### AuthorizationServiceConfiguration Constructor Signature Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationServiceConfiguration/AuthorizationServiceConfiguration.html Defines the required and optional parameters for creating an AuthorizationServiceConfiguration instance. ```dart const AuthorizationServiceConfiguration({ 1. required String authorizationEndpoint, 2. required String tokenEndpoint, 3. String? endSessionEndpoint, }) ``` -------------------------------- ### Prompt Class Constants Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/Prompt-class.html These constants represent the different values for the OpenID Connect 1.0 `prompt` parameter, which controls user interaction during authentication and authorization flows. ```APIDOC ## Prompt Class Constants ### Description These constants represent the different values for the OpenID Connect 1.0 `prompt` parameter, which controls user interaction during authentication and authorization flows. ### Constants - **consent** (String) - The Authorization Server SHOULD prompt the End-User for consent before returning information to the Client. - **login** (String) - The Authorization Server SHOULD prompt the End-User for re-authentication. - **none** (String) - The Authorization Server MUST NOT display any authentication or consent user interface pages. - **selectAccount** (String) - The Authorization Server SHOULD prompt the End-User to select a user account. ``` -------------------------------- ### authorizeAndExchangeCode Method Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuth/authorizeAndExchangeCode.html This is the implementation of the convenience method for authorizing and then exchanging the authorization code. ```dart Future authorizeAndExchangeCode( AuthorizationTokenRequest request) { return FlutterAppAuthPlatform.instance.authorizeAndExchangeCode(request); } ``` -------------------------------- ### Assert Configuration Info Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/EndSessionRequest/assertConfigurationInfo.html Ensures that at least one of issuer, discoveryUrl, or serviceConfiguration is non-null. Throws an assertion error if none are provided. ```dart void assertConfigurationInfo() { assert( issuer != null || discoveryUrl != null || serviceConfiguration != null, 'Either the issuer, discovery URL or service configuration must be ' 'provided'); } ``` -------------------------------- ### loginHint Property Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationTokenRequest/loginHint.html A hint to the Authorization Server about the login identifier the end-user might use to log in. This is a nullable String. ```APIDOC ## loginHint Property ### Description Hint to the Authorization Server about the login identifier the End-User might use to log in. ### Type String? ### Getter/Setter Inherited ``` -------------------------------- ### TokenRequest Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/TokenRequest/TokenRequest.html Constructs a new TokenRequest with the specified client ID, redirect URL, and optional parameters for authorization. ```APIDOC ## TokenRequest Constructor ### Description Initializes a TokenRequest object used for OAuth 2.0 authorization flows. It requires essential client information and supports various optional parameters to customize the authorization request. ### Parameters #### Positional Parameters - **clientId** (String) - Required - The client identifier. - **redirectUrl** (String) - Required - The URL to redirect to after authorization. #### Optional Parameters - **clientSecret** (String?) - Optional - The client secret, if applicable. - **scopes** (List?) - Optional - A list of scopes to request. - **issuer** (String?) - Optional - The issuer identifier for the authorization server. - **discoveryUrl** (String?) - Optional - The URL for the OAuth 2.0 discovery endpoint. - **serviceConfiguration** (AuthorizationServiceConfiguration?) - Optional - Pre-configured service endpoints. - **additionalParameters** (Map?) - Optional - Additional parameters to include in the request. - **nonce** (String?) - Optional - A nonce value for security. - **refreshToken** (String?) - Optional - A refresh token, if applicable. - **grantType** (String?) - Optional - The grant type for the request. - **authorizationCode** (String?) - Optional - The authorization code received. - **codeVerifier** (String?) - Optional - The code verifier for PKCE. - **allowInsecureConnections** (bool) - Optional - Allows insecure connections (default: false). ``` -------------------------------- ### EndSessionResponse Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/EndSessionResponse-class.html Constructs an EndSessionResponse object. It optionally takes a state string. ```APIDOC ## EndSessionResponse ### Description Represents the response from performing an end session/logout request. ### Constructors #### EndSessionResponse - **state** (String?) - Optional - The state parameter from the logout response. ``` -------------------------------- ### Configure Redirect Scheme in build.gradle Source: https://pub.dev/documentation/flutter_appauth/latest/index.html Specify the custom redirect scheme for your Android app using the `build.gradle` file. Replace `` with your desired scheme. ```groovy android { ... defaultConfig { ... manifestPlaceholders += [ 'appAuthRedirectScheme': '' ] } } ``` -------------------------------- ### Configure Redirect Scheme in build.gradle.kts Source: https://pub.dev/documentation/flutter_appauth/latest/index.html Specify the custom redirect scheme for your Android app using the `build.gradle.kts` file. Replace `` with your desired scheme. ```kotlin android { ... defaultConfig { ... manifestPlaceholders.putAll( mapOf( "appAuthRedirectScheme" to "" ) ) } } ``` -------------------------------- ### Authorize Method Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuth/authorize.html This snippet shows the implementation of the authorize method, which delegates the call to the FlutterAppAuthPlatform instance. ```dart Future authorize(AuthorizationRequest request) { return FlutterAppAuthPlatform.instance.authorize(request); } ``` -------------------------------- ### AuthorizationResponse Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationResponse/AuthorizationResponse.html Constructs an AuthorizationResponse object with optional parameters for authorization code, code verifier, nonce, and additional parameters. ```APIDOC ## AuthorizationResponse Constructor ### Description Initializes an AuthorizationResponse object. This constructor allows for the optional provision of an authorization code, a code verifier, a nonce, and a map of additional authorization parameters. ### Parameters #### Constructor Parameters - **authorizationCode** (String?) - Optional - The authorization code received. - **codeVerifier** (String?) - Optional - The code verifier used in the authorization request. - **nonce** (String?) - Optional - The nonce value used in the authorization request. - **authorizationAdditionalParameters** (Map?) - Optional - A map containing any additional parameters associated with the authorization response. ### Implementation ```dart const AuthorizationResponse({ this.authorizationCode, this.codeVerifier, this.nonce, this.authorizationAdditionalParameters, }); ``` ``` -------------------------------- ### TokenResponse Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/TokenResponse-class.html Constructs a TokenResponse object with details from a successful token exchange. ```APIDOC ## TokenResponse Constructor ### Description Initializes a new instance of the TokenResponse class with the provided token details. ### Parameters * **accessToken** (String?) - The access token string. * **refreshToken** (String?) - The refresh token string. * **accessTokenExpirationDateTime** (DateTime?) - The expiration date and time of the access token. * **idToken** (String?) - The ID token string. * **tokenType** (String?) - The type of the token. * **scopes** (List?) - A list of scopes associated with the access token. * **tokenAdditionalParameters** (Map?) - A map of additional parameters returned by the authorization server. ``` -------------------------------- ### AuthorizationRequest Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationRequest/AuthorizationRequest.html The implementation of the AuthorizationRequest constructor assigns the provided parameters to the instance variables and calls assertConfigurationInfo(). ```dart AuthorizationRequest( String clientId, String redirectUrl, { String? issuer, String? discoveryUrl, AuthorizationServiceConfiguration? serviceConfiguration, String? loginHint, List? scopes, Map? additionalParameters, List? promptValues, bool allowInsecureConnections = false, ExternalUserAgent externalUserAgent = ExternalUserAgent.asWebAuthenticationSession, String? nonce, String? responseMode, }) { this.clientId = clientId; this.redirectUrl = redirectUrl; this.scopes = scopes; this.serviceConfiguration = serviceConfiguration; this.additionalParameters = additionalParameters; this.issuer = issuer; this.discoveryUrl = discoveryUrl; this.loginHint = loginHint; this.promptValues = promptValues; this.allowInsecureConnections = allowInsecureConnections; this.externalUserAgent = externalUserAgent; this.nonce = nonce; this.responseMode = responseMode; assertConfigurationInfo(); } ``` -------------------------------- ### TokenRequest Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/TokenRequest-class.html Initializes a TokenRequest object with details for a token exchange. This constructor allows for various parameters to be set, including client credentials, redirect URLs, scopes, and additional parameters for the request. ```APIDOC ## TokenRequest Constructor ### Description Initializes a TokenRequest object with details for a token exchange. ### Parameters * **clientId** (String) - The client ID for the request. * **redirectUrl** (String) - The redirect URL for the request. * **clientSecret** (String?) - Optional client secret. * **scopes** (List?) - Optional list of scopes. * **issuer** (String?) - Optional issuer URL. * **discoveryUrl** (String?) - Optional discovery document URL. * **serviceConfiguration** (AuthorizationServiceConfiguration?) - Optional OAuth 2.0 service configuration. * **additionalParameters** (Map?) - Optional additional parameters. * **nonce** (String?) - Optional nonce value. * **refreshToken** (String?) - Optional refresh token. * **grantType** (String?) - Optional grant type. * **authorizationCode** (String?) - Optional authorization code. * **codeVerifier** (String?) - Optional code verifier. * **allowInsecureConnections** (bool) - Optional flag to allow non-HTTPS endpoints (defaults to false). ``` -------------------------------- ### authorize Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuth-class.html Sends an authorization request to the authorization server. ```APIDOC ## Methods ### authorize **Description**: Initiates the authorization flow by sending an authorization request to the configured authorization server. This method is typically used to obtain an authorization code. **Signature**: `Future authorize(AuthorizationRequest request)` **Parameters**: - **request** (AuthorizationRequest): An object containing the details of the authorization request, such as client ID, redirect URL, scopes, and state. ``` -------------------------------- ### Authorize and Exchange Code using Discovery URL Source: https://pub.dev/documentation/flutter_appauth/latest/index.html Perform an authorization request and automatically exchange the authorization code using an OpenID Connect Discovery URL. Replace placeholders with your actual client ID, redirect URL, and discovery URL. Ensure the scopes are appropriate for your application. ```dart final AuthorizationTokenResponse result = await appAuth.authorizeAndExchangeCode( AuthorizationTokenRequest( '', '', discoveryUrl: '', scopes: ['openid','profile', 'email', 'offline_access', 'api'], ), ); ``` -------------------------------- ### AuthorizationTokenResponse Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationTokenResponse-class.html Constructs an AuthorizationTokenResponse object with details from an authorization and token exchange. ```APIDOC ## AuthorizationTokenResponse ### Description Represents the details obtained from a successful combined authorization and token exchange request. ### Parameters - **accessToken** (String?) - The access token returned by the authorization server. - **refreshToken** (String?) - The refresh token returned by the authorization server. - **accessTokenExpirationDateTime** (DateTime?) - Indicates when the access token will expire. - **idToken** (String?) - The ID token returned by the authorization server. - **tokenType** (String?) - The type of token returned by the authorization server. - **scopes** (List?) - Scopes of the access token. Optional if identical to those originally requested. - **authorizationAdditionalParameters** (Map?) - Additional parameters from the authorization request. - **tokenAdditionalParameters** (Map?) - Additional parameters from the token request. ``` -------------------------------- ### AuthorizationServiceConfiguration Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationServiceConfiguration/AuthorizationServiceConfiguration.html Constructs an instance of AuthorizationServiceConfiguration with the required authorization and token endpoints, and an optional end session endpoint. ```APIDOC ## AuthorizationServiceConfiguration ### Description Constructs an instance of AuthorizationServiceConfiguration with the required authorization and token endpoints, and an optional end session endpoint. ### Parameters #### Path Parameters - **authorizationEndpoint** (String) - Required - The URL for the authorization endpoint. - **tokenEndpoint** (String) - Required - The URL for the token endpoint. - **endSessionEndpoint** (String?) - Optional - The URL for the end session endpoint. ``` -------------------------------- ### EndSessionResponse Constructor Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/EndSessionResponse/EndSessionResponse.html Provides the implementation for the EndSessionResponse constructor, initializing the state property. ```dart EndSessionResponse(this.state); ``` -------------------------------- ### AuthorizationServiceConfiguration Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationServiceConfiguration-class.html Constructs an AuthorizationServiceConfiguration with the required authorization and token endpoints, and an optional end session endpoint. ```APIDOC ## AuthorizationServiceConfiguration ### Description Constructs an AuthorizationServiceConfiguration with the required authorization and token endpoints, and an optional end session endpoint. ### Parameters #### Path Parameters - **authorizationEndpoint** (String) - Required - The URL for the authorization endpoint. - **tokenEndpoint** (String) - Required - The URL for the token endpoint. - **endSessionEndpoint** (String?) - Optional - The URL for the end session endpoint. ``` -------------------------------- ### TokenRequest Constructor Signature Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/TokenRequest/TokenRequest.html Defines the parameters for creating a TokenRequest. Includes required client ID and redirect URL, with optional parameters for client secret, scopes, and more. ```dart TokenRequest( 1. String clientId, 2. String redirectUrl, { 3. String? clientSecret, 4. List? scopes, 5. String? issuer, 6. String? discoveryUrl, 7. AuthorizationServiceConfiguration? serviceConfiguration, 8. Map? additionalParameters, 9. String? nonce, 10. String? refreshToken, 11. String? grantType, 12. String? authorizationCode, 13. String? codeVerifier, 14. bool allowInsecureConnections = false, ) ``` -------------------------------- ### Assert Configuration Information Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationRequest/assertConfigurationInfo.html Ensures that at least one of issuer, discoveryUrl, or serviceConfiguration is provided. This method is called internally to validate request parameters before proceeding. ```dart void assertConfigurationInfo() { assert( issuer != null || discoveryUrl != null || serviceConfiguration != null, 'Either the issuer, discovery URL or service configuration must be ' \ 'provided'); } ``` -------------------------------- ### authorize method Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuth/authorize.html Sends an authorization request to the authorization server's authorization endpoint. ```APIDOC ## authorize method ### Description Sends an authorization request. This is done by sending a request to the authorization server's authorization endpoint. ### Method Signature Future authorize(AuthorizationRequest request) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response - **AuthorizationResponse** (AuthorizationResponse) - The response from the authorization server. ### Response Example None ``` -------------------------------- ### fromMap static method Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuthPlatformErrorDetails/fromMap.html Creates a FlutterAppAuthPlatformErrorDetails instance from a map. This is useful for deserializing platform error responses. ```APIDOC ## fromMap static method ### Description Creates a `FlutterAppAuthPlatformErrorDetails` instance from a map. This is useful for deserializing platform error responses. ### Method Signature `static FlutterAppAuthPlatformErrorDetails fromMap(Map map)` ### Parameters #### Path Parameters - **map** (Map) - Required - A map containing the error details. ### Returns - `FlutterAppAuthPlatformErrorDetails` - An instance of `FlutterAppAuthPlatformErrorDetails` populated with data from the map. ### Example ```dart final errorMap = { 'type': 'auth_error', 'code': 'invalid_grant', 'error': 'error_code', 'error_description': 'The provided grant is invalid.', 'error_uri': 'http://example.com/error', 'domain': 'com.example.auth', 'root_cause_debug_description': 'Root cause details', 'error_debug_description': 'Debug details for the error', }; final errorDetails = FlutterAppAuthPlatformErrorDetails.fromMap(errorMap); print(errorDetails.type); // Output: auth_error print(errorDetails.code); // Output: invalid_grant ``` ``` -------------------------------- ### iOS/macOS Info.plist Custom Scheme Configuration Source: https://pub.dev/documentation/flutter_appauth/latest/index.html Add this section to your app's Info.plist file to define a custom URL scheme for authentication redirects. Replace '' with your application's unique scheme. ```xml CFBundleURLTypes CFBundleTypeRole Editor CFBundleURLSchemes ``` -------------------------------- ### Authorize and Exchange Code using Issuer URL Source: https://pub.dev/documentation/flutter_appauth/latest/index.html This method simplifies the process by using the issuer URL, which allows the SDK to retrieve the discovery document automatically. Replace placeholders with your actual client ID, redirect URL, and issuer URL. ```dart final AuthorizationTokenResponse result = await appAuth.authorizeAndExchangeCode( AuthorizationTokenRequest( '', '', issuer: '', scopes: ['openid','profile', 'email', 'offline_access', 'api'], ), ); ``` -------------------------------- ### authorizeAndExchangeCode Method Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuth/authorizeAndExchangeCode.html Convenience method for authorizing and then exchanging the authorization code. ```APIDOC ## authorizeAndExchangeCode ### Description Convenience method for authorizing and then exchanges code. ### Method Signature Future authorizeAndExchangeCode(AuthorizationTokenRequest request) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **request** (AuthorizationTokenRequest) - Required - The request object containing authorization parameters. ### Request Example ```dart // Example usage (assuming AuthorizationTokenRequest is defined elsewhere) // final AuthorizationTokenResponse response = await flutterAppAuth.authorizeAndExchangeCode( // AuthorizationTokenRequest( // clientId: '...', // scopes: ['...'], // redirectUrl: '...', // // other parameters... // ) // ); ``` ### Response #### Success Response Returns a `Future` containing the authorization and token details upon successful completion. #### Response Example ```json // Example response structure (actual fields depend on the OAuth provider) { "accessToken": "...", "idToken": "...", "tokenType": "Bearer", "expiresIn": 3600, "refreshToken": "..." } ``` ### Error Handling Refer to the underlying platform implementation for specific error handling and exceptions. ``` -------------------------------- ### FlutterAppAuthPlatformException Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuthPlatformException/FlutterAppAuthPlatformException.html Constructs an instance of FlutterAppAuthPlatformException with the provided error details. ```APIDOC ## FlutterAppAuthPlatformException Constructor ### Description Constructs an instance of FlutterAppAuthPlatformException with the provided error details. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **code** (String) - Required - The error code. - **message** (String?) - Optional - The error message. - **legacyDetails** (dynamic) - Optional - Legacy details for the error. - **stacktrace** (String?) - Optional - The stack trace of the error. - **platformErrorDetails** (FlutterAppAuthPlatformErrorDetails) - Required - Platform-specific error details. ### Implementation ```dart FlutterAppAuthPlatformException({ required super.code, super.message, dynamic legacyDetails, super.stacktrace, required this.platformErrorDetails, }) : super( details: legacyDetails, ); ``` ``` -------------------------------- ### AuthorizationTokenRequest Constructor Signature Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationTokenRequest/AuthorizationTokenRequest.html Defines the parameters for creating an AuthorizationTokenRequest. Includes required client ID and redirect URL, with optional parameters for login hints, client secrets, scopes, service configuration, and more. ```dart AuthorizationTokenRequest( 1. String clientId, 2. String redirectUrl, { 3. String? loginHint, 4. String? clientSecret, 5. List? scopes, 6. AuthorizationServiceConfiguration? serviceConfiguration, 7. Map? additionalParameters, 8. String? issuer, 9. String? discoveryUrl, 10. List? promptValues, 11. bool allowInsecureConnections = false, 12. ExternalUserAgent externalUserAgent = ExternalUserAgent.asWebAuthenticationSession, 13. String? nonce, 14. String? responseMode, }) ``` -------------------------------- ### AuthorizationTokenResponse Constructor Signature Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationTokenResponse/AuthorizationTokenResponse.html Defines the parameters accepted by the AuthorizationTokenResponse constructor. ```dart AuthorizationTokenResponse( String? accessToken, String? refreshToken, DateTime? accessTokenExpirationDateTime, String? idToken, String? tokenType, List? scopes, Map? authorizationAdditionalParameters, Map? tokenAdditionalParameters, ) ``` -------------------------------- ### AuthorizationTokenResponse Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationTokenResponse/AuthorizationTokenResponse.html Constructs an instance of AuthorizationTokenResponse. This class holds the tokens and related information obtained during an authorization flow. ```APIDOC ## AuthorizationTokenResponse() ### Description Constructs an instance of AuthorizationTokenResponse. This class holds the tokens and related information obtained during an authorization flow. ### Parameters #### Constructor Parameters - **accessToken** (String?) - The access token received. - **refreshToken** (String?) - The refresh token received. - **accessTokenExpirationDateTime** (DateTime?) - The expiration date and time of the access token. - **idToken** (String?) - The ID token received. - **tokenType** (String?) - The type of the token (e.g., 'Bearer'). - **scopes** (List?) - A list of scopes granted. - **authorizationAdditionalParameters** (Map?) - Additional parameters from the authorization request. - **tokenAdditionalParameters** (Map?) - Additional parameters from the token request. ### Example ```dart final authResponse = AuthorizationTokenResponse( 'ACCESS_TOKEN_STRING', 'REFRESH_TOKEN_STRING', DateTime.now().add(const Duration(hours: 1)), 'ID_TOKEN_STRING', 'Bearer', ['read', 'write'], {'param1': 'value1'}, {'param2': 'value2'}, ); ``` ``` -------------------------------- ### AuthorizationTokenRequest Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationTokenRequest/AuthorizationTokenRequest.html Constructs an AuthorizationTokenRequest object with the specified parameters to initiate an authorization code flow. ```APIDOC ## AuthorizationTokenRequest Constructor ### Description Initializes a new instance of the `AuthorizationTokenRequest` class. This object encapsulates the parameters required to start the authorization code flow with an identity provider. ### Parameters #### Positional Parameters 1. **clientId** (String) - Required - The client ID obtained from the identity provider. 2. **redirectUrl** (String) - Required - The URL to which the identity provider will redirect the user after authorization. #### Named Parameters - **loginHint** (String?) - Optional - A hint to the identity provider about the user who is attempting to log in. - **clientSecret** (String?) - Optional - The client secret for confidential clients. Use with caution and ensure secure storage. - **scopes** (List?) - Optional - A list of scopes requested for the authorization. - **serviceConfiguration** (AuthorizationServiceConfiguration?) - Optional - Configuration details for the authorization service, including endpoints. - **additionalParameters** (Map?) - Optional - A map of additional parameters to be sent with the authorization request. - **issuer** (String?) - Optional - The issuer identifier for the identity provider. - **discoveryUrl** (String?) - Optional - The URL for the OpenID Connect discovery document. - **promptValues** (List?) - Optional - A list of prompt values to control the identity provider's behavior (e.g., 'login', 'consent'). - **allowInsecureConnections** (bool) - Optional - Allows insecure connections (HTTP). Defaults to `false`. Use only for testing or specific development scenarios. - **externalUserAgent** (ExternalUserAgent) - Optional - Specifies the external user agent to use for the authentication process. Defaults to `ExternalUserAgent.asWebAuthenticationSession`. - **nonce** (String?) - Optional - A nonce value to mitigate replay attacks. - **responseMode** (String?) - Optional - Specifies the response mode for the authorization callback (e.g., 'query', 'fragment'). ### Implementation Notes The constructor sets the `grantType` to `GrantType.authorizationCode` internally, indicating that this request is part of the authorization code grant flow. ``` -------------------------------- ### AuthorizationResponse Constructor Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationResponse/AuthorizationResponse.html The implementation of the AuthorizationResponse constructor, used to initialize an instance with optional parameters. ```dart const AuthorizationResponse({ this.authorizationCode, this.codeVerifier, this.nonce, this.authorizationAdditionalParameters, }); ``` -------------------------------- ### TokenRequest Methods Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/TokenRequest-class.html Provides access to methods available for the TokenRequest class, such as assertion of configuration information and string representation. ```APIDOC ## TokenRequest Methods ### Methods * **assertConfigurationInfo() → void** - Asserts that the necessary configuration information is present. * **noSuchMethod(Invocation invocation) → dynamic** - Invoked when a nonexistent method or property is accessed. * **toString() → String** - Returns a string representation of the object. ``` -------------------------------- ### AuthorizationTokenRequest Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationTokenRequest/AuthorizationTokenRequest.html Provides the implementation details for the AuthorizationTokenRequest constructor, setting default grant type to authorizationCode and initializing various properties. ```dart AuthorizationTokenRequest( super.clientId, super.redirectUrl, { String? loginHint, super.clientSecret, super.scopes, super.serviceConfiguration, super.additionalParameters, super.issuer, super.discoveryUrl, List? promptValues, super.allowInsecureConnections, ExternalUserAgent externalUserAgent = ExternalUserAgent.asWebAuthenticationSession, super.nonce, String? responseMode, }) : super( grantType: GrantType.authorizationCode, ) { this.loginHint = loginHint; this.promptValues = promptValues; this.externalUserAgent = externalUserAgent; this.responseMode = responseMode; } ``` -------------------------------- ### FlutterAppAuthPlatformErrorDetails Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuthPlatformErrorDetails-class.html Constructs an instance of FlutterAppAuthPlatformErrorDetails with optional error details. ```APIDOC ## Constructors FlutterAppAuthPlatformErrorDetails({String? type, String? code, String? error, String? errorDescription, String? errorUri, String? domain, String? rootCauseDebugDescription, String? errorDebugDescription}) ``` -------------------------------- ### FlutterAppAuthPlatformException Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuthPlatformException/FlutterAppAuthPlatformException.html The implementation of the FlutterAppAuthPlatformException constructor, which initializes the exception with provided details and forwards relevant parameters to the superclass. ```dart FlutterAppAuthPlatformException({ required super.code, super.message, dynamic legacyDetails, super.stacktrace, required this.platformErrorDetails, }) : super( details: legacyDetails, ); ``` -------------------------------- ### FlutterAppAuthUserCancelledException Constructor Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuthUserCancelledException/FlutterAppAuthUserCancelledException.html Provides the implementation details for the FlutterAppAuthUserCancelledException constructor, including superclass initialization. ```dart FlutterAppAuthUserCancelledException({ required super.code, super.message, dynamic legacyDetails, super.stacktrace, required this.platformErrorDetails, }) : super( details: legacyDetails, ); ``` -------------------------------- ### Configure Redirect URI in AndroidManifest.xml Source: https://pub.dev/documentation/flutter_appauth/latest/index.html Directly configure the redirect URI by adding an intent-filter for AppAuth's RedirectUriReceiverActivity in your `AndroidManifest.xml`. Ensure the scheme and host match your configuration. ```xml ... ... ``` -------------------------------- ### Flutter AppAuth Token Method Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuth/token.html This snippet shows the implementation of the `token` method, which delegates the token exchange request to the `FlutterAppAuthPlatform.instance.token` method. Ensure the `TokenRequest` object is correctly populated before calling this method. ```dart Future token(TokenRequest request) { return FlutterAppAuthPlatform.instance.token(request); } ``` -------------------------------- ### FlutterAppAuthUserCancelledException Constructor Signature Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuthUserCancelledException/FlutterAppAuthUserCancelledException.html Defines the parameters required for creating a FlutterAppAuthUserCancelledException instance. ```dart FlutterAppAuthUserCancelledException({ 1. required String code, 2. String? message, 3. dynamic legacyDetails, 4. String? stacktrace, 5. required FlutterAppAuthPlatformErrorDetails platformErrorDetails, }) ``` -------------------------------- ### AuthorizationRequest Constructor Signature Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationRequest/AuthorizationRequest.html Defines the parameters for creating an AuthorizationRequest. It includes required client and redirect URLs, and optional parameters for issuer, discovery URL, service configuration, scopes, and more. ```dart AuthorizationRequest( 1. String clientId, 2. String redirectUrl, { 3. String? issuer, 4. String? discoveryUrl, 5. AuthorizationServiceConfiguration? serviceConfiguration, 6. String? loginHint, 7. List? scopes, 8. Map? additionalParameters, 9. List? promptValues, 10. bool allowInsecureConnections = false, 11. ExternalUserAgent externalUserAgent = ExternalUserAgent.asWebAuthenticationSession, 12. String? nonce, 13. String? responseMode, }) ``` -------------------------------- ### FlutterAppAuthPlatformException Constructor Signature Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuthPlatformException/FlutterAppAuthPlatformException.html Defines the parameters required for creating a FlutterAppAuthPlatformException. It requires a 'code' and 'platformErrorDetails', with optional 'message', 'legacyDetails', and 'stacktrace'. ```dart FlutterAppAuthPlatformException({ 1. required String code, 2. String? message, 3. dynamic legacyDetails, 4. String? stacktrace, 5. required FlutterAppAuthPlatformErrorDetails platformErrorDetails, }) ``` -------------------------------- ### discoveryUrl Property Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/EndSessionRequest/discoveryUrl.html This snippet shows the declaration of the nullable String discoveryUrl property. It is used to store the URL of the discovery document. ```dart String? discoveryUrl; ``` -------------------------------- ### Use Ephemeral Browser Sessions (iOS/macOS) Source: https://pub.dev/documentation/flutter_appauth/latest/index.html Enable ephemeral browser sessions on iOS (13+) and macOS by setting `preferEphemeralSession = true` for sign-in and sign-out to prevent persistent login sessions. ```dart // Example usage within authorize or endSession calls: // await appAuth.authorize(..., preferEphemeralSession: true); // await appAuth.endSession(..., preferEphemeralSession: true); ``` -------------------------------- ### AuthorizationTokenRequest Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationTokenRequest-class.html Constructs an AuthorizationTokenRequest. This class is used for combined authorization and code exchange requests, requiring essential parameters like clientId and redirectUrl, and offering optional parameters for customization. ```APIDOC ## AuthorizationTokenRequest Constructor ### Description Constructs an AuthorizationTokenRequest. This class is used for combined authorization and code exchange requests, requiring essential parameters like clientId and redirectUrl, and offering optional parameters for customization. ### Parameters - **clientId** (String) - Required - The client ID. - **redirectUrl** (String) - Required - The redirect URL. - **loginHint** (String?) - Optional - Hint to the Authorization Server about the login identifier the End-User might use to log in. - **clientSecret** (String?) - Optional - The client secret. - **scopes** (List?) - Optional - The request scopes. - **serviceConfiguration** (AuthorizationServiceConfiguration?) - Optional - The details of the OAuth 2.0 endpoints that can be explicitly provided when discovery isn't used or not possible. - **additionalParameters** (Map?) - Optional - Additional parameters to include in the request. - **issuer** (String?) - Optional - The issuer. - **discoveryUrl** (String?) - Optional - The URL of where the discovery document can be found. - **promptValues** (List?) - Optional - List of ASCII string values that specifies whether the Authorization Server prompts the End-User for reauthentication and consent. - **allowInsecureConnections** (bool) - Optional - Whether to allow non-HTTPS endpoints. Defaults to false. - **externalUserAgent** (ExternalUserAgent) - Optional - Specifies the external user-agent to use. Defaults to ExternalUserAgent.asWebAuthenticationSession. - **nonce** (String?) - Optional - The nonce. - **responseMode** (String?) - Optional - Specifies the response mode to use. ``` -------------------------------- ### Nonce Property Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationRequest/nonce.html This snippet shows the declaration of the nullable String 'nonce' property. It is inherited and provides a getter/setter pair. ```dart String? nonce; ``` -------------------------------- ### FlutterAppAuthUserCancelledException Methods Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuthUserCancelledException-class.html Methods available on the FlutterAppAuthUserCancelledException class. ```APIDOC ## Methods ### noSuchMethod * **Signature:** dynamic noSuchMethod(Invocation invocation) * **Description:** Invoked when a nonexistent method or property is accessed. * **Inherited:** Yes ### toString * **Signature:** String toString() * **Description:** A string representation of this object. * **Override:** Yes ``` -------------------------------- ### FlutterAppAuthUserCancelledException Constructors Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuthUserCancelledException-class.html Constructs an instance of FlutterAppAuthUserCancelledException. ```APIDOC ## Constructors ### FlutterAppAuthUserCancelledException ```dart FlutterAppAuthUserCancelledException({required String code, String? message, dynamic legacyDetails, String? stacktrace, required FlutterAppAuthPlatformErrorDetails platformErrorDetails}) ``` **Parameters:** * **code** (String) - Required - An error code. * **message** (String?) - Optional - A human-readable error message. * **legacyDetails** (dynamic) - Optional - Legacy error details. * **stacktrace** (String?) - Optional - Native stacktrace for the error. * **platformErrorDetails** (FlutterAppAuthPlatformErrorDetails) - Required - Details of the error from the underlying platform's AppAuth SDK. ``` -------------------------------- ### authorizationAdditionalParameters Property Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationTokenResponse/authorizationAdditionalParameters.html This property contains additional parameters returned by the authorization server from making the authorization request. It is a final Map?. ```APIDOC ## authorizationAdditionalParameters Property ### Description This property holds additional parameters returned by the authorization server from making the authorization request. ### Type `Map?` ### Modifiers `final` ### Implementation ```dart final Map? authorizationAdditionalParameters; ``` ``` -------------------------------- ### FlutterAppAuth Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuth/FlutterAppAuth.html The default constructor for the FlutterAppAuth class. No arguments are required. ```dart const FlutterAppAuth(); ``` -------------------------------- ### EndSessionRequest Constructor Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/EndSessionRequest/EndSessionRequest.html This snippet shows the implementation of the EndSessionRequest constructor, including parameter assignments. It is used when creating a request to end a user's session. ```dart EndSessionRequest({ this.idTokenHint, this.postLogoutRedirectUrl, this.state, this.allowInsecureConnections = false, this.externalUserAgent = ExternalUserAgent.asWebAuthenticationSession, this.additionalParameters, String? issuer, String? discoveryUrl, AuthorizationServiceConfiguration? serviceConfiguration, }) { this.serviceConfiguration = serviceConfiguration; this.issuer = issuer; this.discoveryUrl = discoveryUrl; } ``` -------------------------------- ### TokenRequest Operators Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/TokenRequest-class.html Details the operators available for the TokenRequest class, specifically the equality operator. ```APIDOC ## TokenRequest Operators ### Operators * **operator ==(Object other) → bool** - The equality operator. Compares this object to another for equality. ``` -------------------------------- ### EndSessionRequest Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/EndSessionRequest-class.html Constructs an EndSessionRequest object. This object is used to initiate the end session flow, allowing for the specification of an ID token hint, post-logout redirect URL, state, and other configuration details. ```APIDOC ## EndSessionRequest() ### Description Constructs an EndSessionRequest object. This object is used to initiate the end session flow, allowing for the specification of an ID token hint, post-logout redirect URL, state, and other configuration details. ### Parameters - **idTokenHint** (String?) - Optional - Represents the ID token previously issued to the user. - **postLogoutRedirectUrl** (String?) - Optional - Represents the URL to redirect to after the logout operation has been completed. - **state** (String?) - Optional - A value used to maintain state between the request and callback. - **allowInsecureConnections** (bool) - Optional - Whether to allow non-HTTPS endpoints. Defaults to false. - **externalUserAgent** (ExternalUserAgent?) - Optional - Specifies the external user-agent to use. Defaults to ExternalUserAgent.asWebAuthenticationSession. - **additionalParameters** (Map?) - Optional - Additional parameters to include in the request. - **issuer** (String?) - Optional - The issuer identifier. - **discoveryUrl** (String?) - Optional - The URL of where the discovery document can be found. - **serviceConfiguration** (AuthorizationServiceConfiguration?) - Optional - The details of the OAuth 2.0 endpoints that can be explicitly provided when discovery isn't used or not possible. ``` -------------------------------- ### Authorize and Exchange Code using Explicit Service Configuration Source: https://pub.dev/documentation/flutter_appauth/latest/index.html When discovery is not supported or endpoints are known, explicitly define the authorization and token endpoints. This provides direct control over the OAuth 2.0 communication. ```dart final AuthorizationTokenResponse result = await appAuth.authorizeAndExchangeCode( AuthorizationTokenRequest( '', '', serviceConfiguration: AuthorizationServiceConfiguration(authorizationEndpoint: '', tokenEndpoint: '', endSessionEndpoint: ''), scopes: [...] ), ); ``` -------------------------------- ### clientId Property Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationRequest/clientId.html This snippet shows the declaration of the clientId property as a late String. ```dart late String clientId; ``` -------------------------------- ### EndSessionRequest Constructor Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/EndSessionRequest/EndSessionRequest.html Constructs an EndSessionRequest object with optional parameters for customizing the logout process. ```APIDOC ## EndSessionRequest Constructor ### Description Initializes a new instance of the `EndSessionRequest` class. ### Parameters #### Constructor Parameters - **idTokenHint** (String?) - Optional - The ID token hint to be included in the logout request. - **postLogoutRedirectUrl** (String?) - Optional - The URL to redirect to after the user has logged out. - **state** (String?) - Optional - A state parameter to maintain state between the request and callback. - **allowInsecureConnections** (bool) - Optional - Allows insecure connections (default is false). - **externalUserAgent** (ExternalUserAgent?) - Optional - The external user agent to use for the authentication session (default is `ExternalUserAgent.asWebAuthenticationSession`). - **additionalParameters** (Map?) - Optional - Additional parameters to include in the logout request. - **issuer** (String?) - Optional - The issuer identifier for the authorization server. - **discoveryUrl** (String?) - Optional - The URL for the authorization server's discovery endpoint. - **serviceConfiguration** (AuthorizationServiceConfiguration?) - Optional - The authorization service configuration. ### Implementation Notes The constructor initializes the object with the provided parameters. The `serviceConfiguration`, `issuer`, and `discoveryUrl` are set within the constructor's body. ``` -------------------------------- ### Define 'none' Constant Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/Prompt/none-constant.html Defines the 'none' constant as a string. This is used to indicate that no user interaction should occur during the authorization process. ```dart static const String none = 'none'; ``` -------------------------------- ### FlutterAppAuthOAuthError Class Overview Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/FlutterAppAuthOAuthError-class.html Provides information about the FlutterAppAuthOAuthError class, its constructors, properties, methods, operators, and constants. ```APIDOC ## Class: FlutterAppAuthOAuthError ### Description Represents OAuth error codes that can be returned by the authorization server. These are the standard error codes defined in the OAuth 2.0 framework. ### Constructors * **FlutterAppAuthOAuthError()**: Default constructor for the class. ### Properties * **hashCode** (int): The hash code for this object. (inherited) * **runtimeType** (Type): A representation of the runtime type of the object. (inherited) ### Methods * **noSuchMethod(Invocation invocation)** (dynamic): Invoked when a nonexistent method or property is accessed. (inherited) * **toString()** (String): A string representation of this object. (inherited) ### Operators * **operator ==(Object other)** (bool): The equality operator. (inherited) ### Constants * **invalidClient** (String): Represents an 'invalid_client' OAuth error. * **invalidGrant** (String): Represents an 'invalid_grant' OAuth error. * **invalidRequest** (String): Represents an 'invalid_request' OAuth error. * **invalidScope** (String): Represents an 'invalid_scope' OAuth error. * **unauthorizedClient** (String): Represents an 'unauthorized_client' OAuth error. * **unsupportedGrantType** (String): Represents an 'unsupported_grant_type' OAuth error. ``` -------------------------------- ### discoveryUrl Property Implementation Source: https://pub.dev/documentation/flutter_appauth/latest/flutter_appauth/AuthorizationRequest/discoveryUrl.html This snippet shows the declaration of the discoveryUrl property as a nullable String. It is a getter/setter pair inherited from the base class. ```dart String? discoveryUrl; ```