diff --git a/android/.classpath b/android/.classpath
new file mode 100644
index 0000000..eb19361
--- /dev/null
+++ b/android/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/android/.gitignore b/android/.gitignore
new file mode 100644
index 0000000..c6cbe56
--- /dev/null
+++ b/android/.gitignore
@@ -0,0 +1,8 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
diff --git a/android/.project b/android/.project
new file mode 100644
index 0000000..d47519c
--- /dev/null
+++ b/android/.project
@@ -0,0 +1,23 @@
+
+
+ flutter_web_auth_2
+ Project flutter_web_auth_2 created by Buildship.
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.buildship.core.gradleprojectbuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.buildship.core.gradleprojectnature
+
+
diff --git a/android/.settings/org.eclipse.buildship.core.prefs b/android/.settings/org.eclipse.buildship.core.prefs
new file mode 100644
index 0000000..6aa97a9
--- /dev/null
+++ b/android/.settings/org.eclipse.buildship.core.prefs
@@ -0,0 +1,2 @@
+connection.project.dir=../example/android
+eclipse.preferences.version=1
diff --git a/android/build.gradle b/android/build.gradle
new file mode 100644
index 0000000..ae98d94
--- /dev/null
+++ b/android/build.gradle
@@ -0,0 +1,48 @@
+group 'com.teranet.oauth2_client'
+version '1.0-SNAPSHOT'
+
+buildscript {
+ ext.kotlin_version = '1.7.10'
+ repositories {
+ google()
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:7.2.2'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ }
+}
+
+rootProject.allprojects {
+ repositories {
+ google()
+ mavenCentral()
+ }
+}
+
+apply plugin: 'com.android.library'
+apply plugin: 'kotlin-android'
+
+android {
+ compileSdkVersion 31
+
+ sourceSets {
+ main.java.srcDirs += 'src/main/kotlin'
+ }
+ defaultConfig {
+ minSdkVersion 16
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ lintOptions {
+ disable 'InvalidPackage'
+ }
+
+ dependencies {
+ implementation 'androidx.browser:browser:1.4.0'
+ }
+}
+
+dependencies {
+ implementation 'androidx.wear:wear-phone-interactions:1.0.1'
+}
diff --git a/android/gradle.properties b/android/gradle.properties
new file mode 100644
index 0000000..94adc3a
--- /dev/null
+++ b/android/gradle.properties
@@ -0,0 +1,3 @@
+org.gradle.jvmargs=-Xmx1536M
+android.useAndroidX=true
+android.enableJetifier=true
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..ae04661
--- /dev/null
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/android/settings.gradle b/android/settings.gradle
new file mode 100644
index 0000000..15aa3ff
--- /dev/null
+++ b/android/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'flutter_web_auth_2'
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..e89560b
--- /dev/null
+++ b/android/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/android/src/main/kotlin/com/teranet/oauth2_client/OAuth2ClientPlugin.kt b/android/src/main/kotlin/com/teranet/oauth2_client/OAuth2ClientPlugin.kt
new file mode 100644
index 0000000..ae89b6f
--- /dev/null
+++ b/android/src/main/kotlin/com/teranet/oauth2_client/OAuth2ClientPlugin.kt
@@ -0,0 +1,107 @@
+package com.teranet.oauth2_client
+
+import android.content.Context
+import android.content.pm.PackageManager
+import android.net.Uri
+import android.os.Build
+
+import androidx.wear.phone.interactions.authentication.*
+
+import io.flutter.embedding.engine.plugins.FlutterPlugin
+import io.flutter.plugin.common.BinaryMessenger
+import io.flutter.plugin.common.MethodCall
+import io.flutter.plugin.common.MethodChannel
+import io.flutter.plugin.common.MethodChannel.MethodCallHandler
+import io.flutter.plugin.common.PluginRegistry.Registrar
+import java.util.concurrent.Executors
+
+class OAuth2ClientPlugin(private var context: Context? = null, private var channel: MethodChannel? = null): MethodCallHandler, FlutterPlugin {
+ private lateinit var remoteAuthClient: RemoteAuthClient
+
+ companion object {
+ @JvmStatic
+ fun registerWith(registrar: Registrar) {
+ val plugin = OAuth2ClientPlugin()
+ plugin.initInstance(registrar.messenger(), registrar.context())
+ }
+
+ }
+
+ fun initInstance(messenger: BinaryMessenger, context: Context) {
+ this.context = context
+ remoteAuthClient = RemoteAuthClient.create(context)
+ channel = MethodChannel(messenger, "oauth2_client")
+ channel?.setMethodCallHandler(this)
+ }
+
+ override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
+ initInstance(binding.binaryMessenger, binding.applicationContext)
+ }
+
+ override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
+ context = null
+ channel = null
+ }
+
+ private fun buildWatchAuthUri(url: Uri): Uri? {
+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1 && context != null &&
+ context!!.packageManager.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
+ val context = context!!
+ val request = OAuthRequest.Builder(context)
+ .setAuthProviderUrl(url)
+ .build()
+ request.requestUrl
+ } else {
+ null
+ }
+ }
+
+ override fun onMethodCall(call: MethodCall, resultCallback: MethodChannel.Result) {
+ when (call.method) {
+ "authUrl" -> {
+ val url = call.argument("url")
+ val authUri = buildWatchAuthUri(Uri.parse(url))
+ if (authUri == null) {
+ resultCallback.notImplemented()
+ return
+ }
+ resultCallback.success(authUri.toString())
+ }
+ "authenticate" -> {
+ val url = Uri.parse(call.argument("url")!!)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1 && context != null &&
+ context!!.packageManager.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
+ val context = context!!
+ val request = OAuthRequest.Builder(context)
+ .setAuthProviderUrl(url)
+ .build()
+ remoteAuthClient.sendAuthorizationRequest(request,
+ Executors.newSingleThreadExecutor(),
+ object : RemoteAuthClient.Callback() {
+ override fun onAuthorizationResponse(
+ request: OAuthRequest,
+ response: OAuthResponse
+ ) {
+ resultCallback.success(response.responseUrl.toString())
+ }
+
+ override fun onAuthorizationError(request: OAuthRequest, errorCode: Int) {
+ val message = when (errorCode) {
+ RemoteAuthClient.ERROR_UNSUPPORTED -> "Auth not supported"
+ RemoteAuthClient.ERROR_PHONE_UNAVAILABLE -> "Phone unavailable"
+ else -> "Unknown error: $errorCode"
+ }
+ resultCallback.error(errorCode.toString(), message, "No details")
+ }
+ }
+ )
+ return
+ } else {
+ // Pass through if not compatible
+ resultCallback.notImplemented()
+ }
+ }
+ else -> resultCallback.notImplemented()
+ }
+ }
+}
diff --git a/lib/authorization_response.dart b/lib/authorization_response.dart
index 492bae2..0ed203b 100644
--- a/lib/authorization_response.dart
+++ b/lib/authorization_response.dart
@@ -1,3 +1,5 @@
+import 'package:flutter/services.dart';
+
/// Represents the response to an Authorization Request.
/// see https://tools.ietf.org/html/rfc6749#page-26
class AuthorizationResponse {
@@ -8,6 +10,14 @@ class AuthorizationResponse {
String? error;
String? errorDescription;
+ AuthorizationResponse.fromError(PlatformException exception) {
+ code = exception.code;
+ state = null;
+ queryParams = {};
+ error = exception.code;
+ errorDescription = exception.message;
+ }
+
AuthorizationResponse.fromRedirectUri(
String redirectUri, String? checkState) {
queryParams = Uri.parse(redirectUri).queryParameters;
diff --git a/lib/oauth2_client.dart b/lib/oauth2_client.dart
index 3e13a6e..eef7ef3 100644
--- a/lib/oauth2_client.dart
+++ b/lib/oauth2_client.dart
@@ -6,10 +6,9 @@ import 'package:oauth2_client/access_token_response.dart';
import 'package:oauth2_client/authorization_response.dart';
import 'package:oauth2_client/oauth2_response.dart';
import 'package:oauth2_client/src/oauth2_utils.dart';
+import 'package:oauth2_client/src/wear_auth.dart';
import 'package:random_string/random_string.dart';
-// import 'package:oauth2_client/src/web_auth.dart';
-
import 'src/base_web_auth.dart';
import 'src/web_auth.dart'
// ignore: uri_does_not_exist
@@ -19,6 +18,15 @@ import 'src/web_auth.dart'
enum CredentialsLocation { header, body }
+class AuthorizationWrapper {
+ final AuthorizationResponse authResponse;
+ final String? redirectUrl;
+ AuthorizationWrapper({
+ required this.authResponse,
+ required this.redirectUrl
+ });
+}
+
/// Base class that implements OAuth2 authorization flows.
///
/// It currently supports the following grants:
@@ -153,7 +161,7 @@ class OAuth2Client {
}
try {
- var authResp = await requestAuthorization(
+ var authRespWrapper = await requestAuthorization(
webAuthClient: webAuthClient,
clientId: clientId,
scopes: scopes,
@@ -162,12 +170,18 @@ class OAuth2Client {
state: state,
customParams: authCodeParams,
webAuthOpts: webAuthOpts);
+ var authResp = authRespWrapper.authResponse;
if (authResp.isAccessGranted()) {
if (afterAuthorizationCodeCb != null) {
afterAuthorizationCodeCb(authResp);
}
+ final newTokenParams = Map.from(accessTokenParams ?? {});
+ if (authRespWrapper.redirectUrl != null) {
+ newTokenParams['redirect_uri'] = authRespWrapper.redirectUrl;
+ }
+
tknResp = await requestAccessToken(
httpClient: httpClient,
//If the authorization request was successfull, the code must be set
@@ -177,7 +191,7 @@ class OAuth2Client {
scopes: scopes,
clientSecret: clientSecret,
codeVerifier: codeVerifier,
- customParams: accessTokenParams,
+ customParams: newTokenParams,
customHeaders: accessTokenHeaders);
} else {
tknResp = AccessTokenResponse.errorResponse();
@@ -214,7 +228,7 @@ class OAuth2Client {
}
/// Requests an Authorization Code to be used in the Authorization Code grant.
- Future requestAuthorization(
+ Future requestAuthorization(
{required String clientId,
List? scopes,
String? codeChallenge,
@@ -229,7 +243,7 @@ class OAuth2Client {
state ??= randomAlphaNumeric(25);
}
- final authorizeUrl = getAuthorizeUrl(
+ final authorizeUrlStem = getAuthorizeUrl(
clientId: clientId,
redirectUri: redirectUri,
scopes: scopes,
@@ -238,14 +252,24 @@ class OAuth2Client {
codeChallenge: codeChallenge,
customParams: customParams);
+ final authorizeUrl = await WearAuth.authUrl(url: authorizeUrlStem);
// Present the dialog to the user
- final result = await webAuthClient.authenticate(
+ AuthorizationResponse authResp;
+ try {
+ final result = await webAuthClient.authenticate(
url: authorizeUrl,
callbackUrlScheme: customUriScheme,
redirectUrl: redirectUri,
opts: webAuthOpts);
- return AuthorizationResponse.fromRedirectUri(result, state);
+ authResp = AuthorizationResponse.fromRedirectUri(result, state);
+ } on PlatformException catch(err) {
+ authResp = AuthorizationResponse.fromError(err);
+ }
+ return AuthorizationWrapper(
+ authResponse: authResp,
+ redirectUrl: Uri.parse(authorizeUrl).queryParameters['redirect_uri'],
+ );
}
/// Requests and Access Token using the provided Authorization [code].
diff --git a/lib/src/io_web_auth.dart b/lib/src/io_web_auth.dart
index fdd1fe0..cec06c9 100644
--- a/lib/src/io_web_auth.dart
+++ b/lib/src/io_web_auth.dart
@@ -1,6 +1,8 @@
import 'package:flutter_web_auth_2/flutter_web_auth_2.dart';
import 'base_web_auth.dart';
+import 'wear_auth.dart';
+import 'package:wear_bridge/wear_bridge.dart';
BaseWebAuth createWebAuth() => IoWebAuth();
@@ -11,6 +13,12 @@ class IoWebAuth implements BaseWebAuth {
required String url,
required String redirectUrl,
Map? opts}) async {
+ if (await WearBridge.isWatch()) {
+ return await WearAuth.authenticate(
+ url: url,
+ redirectUrl: redirectUrl,
+ );
+ }
return await FlutterWebAuth2.authenticate(
callbackUrlScheme: callbackUrlScheme,
url: url,
diff --git a/lib/src/wear_auth.dart b/lib/src/wear_auth.dart
new file mode 100644
index 0000000..39c024e
--- /dev/null
+++ b/lib/src/wear_auth.dart
@@ -0,0 +1,41 @@
+import 'package:flutter/services.dart';
+
+class WearAuth {
+ static const MethodChannel _channel = MethodChannel('oauth2_client');
+
+ static Future authenticate({
+ required String redirectUrl,
+ required String url,
+ }) async {
+ final oldUri = Uri.parse(url);
+ final query = Map.from(oldUri.queryParameters);
+ query.remove('redirect_uri');
+ final newUri = oldUri.replace(
+ queryParameters: query,
+ );
+ final resultUrl = await _channel.invokeMethod('authenticate', {
+ 'redirectUrl': redirectUrl,
+ 'url': newUri.toString(),
+ });
+ return resultUrl!;
+ }
+
+ static Future authUrl({
+ required String url,
+ }) async {
+ final oldUri = Uri.parse(url);
+ final query = Map.from(oldUri.queryParameters);
+ query.remove('redirect_uri');
+ final newUri = oldUri.replace(
+ queryParameters: query,
+ );
+ try {
+ final String authUrl = await _channel.invokeMethod('authUrl', {
+ 'url': newUri.toString(),
+ });
+ return authUrl;
+ } on MissingPluginException {
+ return url;
+ }
+ }
+}
diff --git a/pubspec.yaml b/pubspec.yaml
index cee551c..4f29ed6 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -16,6 +16,7 @@ dependencies:
http: ^0.13.4
meta: ^1.7.0
random_string: ^2.3.1
+ wear_bridge: 0.0.2
dev_dependencies:
flutter_test:
@@ -25,7 +26,12 @@ dev_dependencies:
flutter_lints: ^2.0.0
# The following section is specific to Flutter.
-flutter: null
+flutter:
+ plugin:
+ platforms:
+ android:
+ package: com.teranet.oauth2_client
+ pluginClass: OAuth2ClientPlugin
# To add assets to your package, add an assets section, like this:
# assets:
diff --git a/test/oauth2_client_test.dart b/test/oauth2_client_test.dart
index 69c55a8..38a876a 100644
--- a/test/oauth2_client_test.dart
+++ b/test/oauth2_client_test.dart
@@ -66,7 +66,7 @@ void main() {
codeChallenge: codeChallenge,
state: state);
- expect(authResponse.code, authCode);
+ expect(authResponse.authResponse.code, authCode);
});
test('Fetch Access Token', () async {
@@ -541,7 +541,7 @@ void main() {
codeChallenge: codeChallenge,
enableState: false);
- expect(authResponse.code, authCode);
+ expect(authResponse.authResponse.code, authCode);
});
});
diff --git a/test/oauth2_client_test.mocks.dart b/test/oauth2_client_test.mocks.dart
index cd872f0..bd8d07c 100644
--- a/test/oauth2_client_test.mocks.dart
+++ b/test/oauth2_client_test.mocks.dart
@@ -1,4 +1,4 @@
-// Mocks generated by Mockito 5.3.0 from annotations
+// Mocks generated by Mockito 5.3.2 from annotations
// in oauth2_client/test/oauth2_client_test.dart.
// Do not manually edit this file.
@@ -23,14 +23,24 @@ import 'package:oauth2_client/src/base_web_auth.dart' as _i3;
// ignore_for_file: subtype_of_sealed_class
class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response {
- _FakeResponse_0(Object parent, Invocation parentInvocation)
- : super(parent, parentInvocation);
+ _FakeResponse_0(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
}
class _FakeStreamedResponse_1 extends _i1.SmartFake
implements _i2.StreamedResponse {
- _FakeStreamedResponse_1(Object parent, Invocation parentInvocation)
- : super(parent, parentInvocation);
+ _FakeStreamedResponse_1(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
}
/// A class which mocks [BaseWebAuth].
@@ -42,19 +52,25 @@ class MockBaseWebAuth extends _i1.Mock implements _i3.BaseWebAuth {
}
@override
- _i4.Future authenticate(
- {String? callbackUrlScheme,
- String? url,
- String? redirectUrl,
- Map? opts}) =>
+ _i4.Future authenticate({
+ required String? callbackUrlScheme,
+ required String? url,
+ required String? redirectUrl,
+ Map? opts,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#authenticate, [], {
+ Invocation.method(
+ #authenticate,
+ [],
+ {
#callbackUrlScheme: callbackUrlScheme,
#url: url,
#redirectUrl: redirectUrl,
- #opts: opts
- }),
- returnValue: _i4.Future.value('')) as _i4.Future);
+ #opts: opts,
+ },
+ ),
+ returnValue: _i4.Future.value(''),
+ ) as _i4.Future);
}
/// A class which mocks [Client].
@@ -66,100 +82,213 @@ class MockClient extends _i1.Mock implements _i2.Client {
}
@override
- _i4.Future<_i2.Response> head(Uri? url, {Map? headers}) =>
- (super.noSuchMethod(Invocation.method(#head, [url], {#headers: headers}),
- returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
- this, Invocation.method(#head, [url], {#headers: headers}))))
- as _i4.Future<_i2.Response>);
+ _i4.Future<_i2.Response> head(
+ Uri? url, {
+ Map? headers,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #head,
+ [url],
+ {#headers: headers},
+ ),
+ returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
+ this,
+ Invocation.method(
+ #head,
+ [url],
+ {#headers: headers},
+ ),
+ )),
+ ) as _i4.Future<_i2.Response>);
@override
- _i4.Future<_i2.Response> get(Uri? url, {Map? headers}) =>
- (super.noSuchMethod(Invocation.method(#get, [url], {#headers: headers}),
- returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
- this, Invocation.method(#get, [url], {#headers: headers}))))
- as _i4.Future<_i2.Response>);
+ _i4.Future<_i2.Response> get(
+ Uri? url, {
+ Map? headers,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #get,
+ [url],
+ {#headers: headers},
+ ),
+ returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
+ this,
+ Invocation.method(
+ #get,
+ [url],
+ {#headers: headers},
+ ),
+ )),
+ ) as _i4.Future<_i2.Response>);
@override
- _i4.Future<_i2.Response> post(Uri? url,
- {Map? headers,
- Object? body,
- _i5.Encoding? encoding}) =>
- (super
- .noSuchMethod(Invocation.method(#post, [url], {#headers: headers, #body: body, #encoding: encoding}),
- returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
- this,
- Invocation.method(#post, [
- url
- ], {
- #headers: headers,
- #body: body,
- #encoding: encoding
- })))) as _i4.Future<_i2.Response>);
+ _i4.Future<_i2.Response> post(
+ Uri? url, {
+ Map? headers,
+ Object? body,
+ _i5.Encoding? encoding,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #post,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
+ this,
+ Invocation.method(
+ #post,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ )),
+ ) as _i4.Future<_i2.Response>);
@override
- _i4.Future<_i2.Response> put(Uri? url,
- {Map? headers,
- Object? body,
- _i5.Encoding? encoding}) =>
- (super
- .noSuchMethod(Invocation.method(#put, [url], {#headers: headers, #body: body, #encoding: encoding}),
- returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
- this,
- Invocation.method(#put, [
- url
- ], {
- #headers: headers,
- #body: body,
- #encoding: encoding
- })))) as _i4.Future<_i2.Response>);
+ _i4.Future<_i2.Response> put(
+ Uri? url, {
+ Map? headers,
+ Object? body,
+ _i5.Encoding? encoding,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #put,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
+ this,
+ Invocation.method(
+ #put,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ )),
+ ) as _i4.Future<_i2.Response>);
@override
- _i4.Future<_i2.Response> patch(Uri? url,
- {Map? headers,
- Object? body,
- _i5.Encoding? encoding}) =>
- (super
- .noSuchMethod(Invocation.method(#patch, [url], {#headers: headers, #body: body, #encoding: encoding}),
- returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
- this,
- Invocation.method(#patch, [
- url
- ], {
- #headers: headers,
- #body: body,
- #encoding: encoding
- })))) as _i4.Future<_i2.Response>);
+ _i4.Future<_i2.Response> patch(
+ Uri? url, {
+ Map? headers,
+ Object? body,
+ _i5.Encoding? encoding,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #patch,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
+ this,
+ Invocation.method(
+ #patch,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ )),
+ ) as _i4.Future<_i2.Response>);
@override
- _i4.Future<_i2.Response> delete(Uri? url,
- {Map? headers,
- Object? body,
- _i5.Encoding? encoding}) =>
- (super
- .noSuchMethod(Invocation.method(#delete, [url], {#headers: headers, #body: body, #encoding: encoding}),
- returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
- this,
- Invocation.method(#delete, [
- url
- ], {
- #headers: headers,
- #body: body,
- #encoding: encoding
- })))) as _i4.Future<_i2.Response>);
+ _i4.Future<_i2.Response> delete(
+ Uri? url, {
+ Map? headers,
+ Object? body,
+ _i5.Encoding? encoding,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #delete,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ returnValue: _i4.Future<_i2.Response>.value(_FakeResponse_0(
+ this,
+ Invocation.method(
+ #delete,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ )),
+ ) as _i4.Future<_i2.Response>);
@override
- _i4.Future read(Uri? url, {Map? headers}) =>
- (super.noSuchMethod(Invocation.method(#read, [url], {#headers: headers}),
- returnValue: _i4.Future.value('')) as _i4.Future);
+ _i4.Future read(
+ Uri? url, {
+ Map? headers,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #read,
+ [url],
+ {#headers: headers},
+ ),
+ returnValue: _i4.Future.value(''),
+ ) as _i4.Future);
@override
- _i4.Future<_i6.Uint8List> readBytes(Uri? url,
- {Map? headers}) =>
+ _i4.Future<_i6.Uint8List> readBytes(
+ Uri? url, {
+ Map? headers,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#readBytes, [url], {#headers: headers}),
- returnValue: _i4.Future<_i6.Uint8List>.value(_i6.Uint8List(0)))
- as _i4.Future<_i6.Uint8List>);
+ Invocation.method(
+ #readBytes,
+ [url],
+ {#headers: headers},
+ ),
+ returnValue: _i4.Future<_i6.Uint8List>.value(_i6.Uint8List(0)),
+ ) as _i4.Future<_i6.Uint8List>);
@override
_i4.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) =>
- (super.noSuchMethod(Invocation.method(#send, [request]),
- returnValue: _i4.Future<_i2.StreamedResponse>.value(
- _FakeStreamedResponse_1(
- this, Invocation.method(#send, [request]))))
- as _i4.Future<_i2.StreamedResponse>);
+ (super.noSuchMethod(
+ Invocation.method(
+ #send,
+ [request],
+ ),
+ returnValue:
+ _i4.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1(
+ this,
+ Invocation.method(
+ #send,
+ [request],
+ ),
+ )),
+ ) as _i4.Future<_i2.StreamedResponse>);
@override
- void close() => super.noSuchMethod(Invocation.method(#close, []),
- returnValueForMissingStub: null);
+ void close() => super.noSuchMethod(
+ Invocation.method(
+ #close,
+ [],
+ ),
+ returnValueForMissingStub: null,
+ );
}
diff --git a/test/oauth2_helper_test.mocks.dart b/test/oauth2_helper_test.mocks.dart
index ca03fc9..3f2507c 100644
--- a/test/oauth2_helper_test.mocks.dart
+++ b/test/oauth2_helper_test.mocks.dart
@@ -1,21 +1,20 @@
-// Mocks generated by Mockito 5.3.0 from annotations
+// Mocks generated by Mockito 5.3.2 from annotations
// in oauth2_client/test/oauth2_helper_test.dart.
// Do not manually edit this file.
// ignore_for_file: no_leading_underscores_for_library_prefixes
-import 'dart:async' as _i9;
-import 'dart:convert' as _i10;
-import 'dart:typed_data' as _i11;
+import 'dart:async' as _i8;
+import 'dart:convert' as _i9;
+import 'dart:typed_data' as _i10;
import 'package:http/http.dart' as _i6;
import 'package:mockito/mockito.dart' as _i1;
import 'package:oauth2_client/access_token_response.dart' as _i3;
-import 'package:oauth2_client/authorization_response.dart' as _i4;
-import 'package:oauth2_client/oauth2_client.dart' as _i8;
+import 'package:oauth2_client/oauth2_client.dart' as _i4;
import 'package:oauth2_client/oauth2_response.dart' as _i5;
import 'package:oauth2_client/src/base_storage.dart' as _i7;
import 'package:oauth2_client/src/base_web_auth.dart' as _i2;
-import 'package:oauth2_client/src/token_storage.dart' as _i12;
+import 'package:oauth2_client/src/token_storage.dart' as _i11;
// ignore_for_file: type=lint
// ignore_for_file: avoid_redundant_argument_values
@@ -29,131 +28,214 @@ import 'package:oauth2_client/src/token_storage.dart' as _i12;
// ignore_for_file: subtype_of_sealed_class
class _FakeBaseWebAuth_0 extends _i1.SmartFake implements _i2.BaseWebAuth {
- _FakeBaseWebAuth_0(Object parent, Invocation parentInvocation)
- : super(parent, parentInvocation);
+ _FakeBaseWebAuth_0(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
}
class _FakeAccessTokenResponse_1 extends _i1.SmartFake
implements _i3.AccessTokenResponse {
- _FakeAccessTokenResponse_1(Object parent, Invocation parentInvocation)
- : super(parent, parentInvocation);
+ _FakeAccessTokenResponse_1(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
}
-class _FakeAuthorizationResponse_2 extends _i1.SmartFake
- implements _i4.AuthorizationResponse {
- _FakeAuthorizationResponse_2(Object parent, Invocation parentInvocation)
- : super(parent, parentInvocation);
+class _FakeAuthorizationWrapper_2 extends _i1.SmartFake
+ implements _i4.AuthorizationWrapper {
+ _FakeAuthorizationWrapper_2(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
}
class _FakeOAuth2Response_3 extends _i1.SmartFake
implements _i5.OAuth2Response {
- _FakeOAuth2Response_3(Object parent, Invocation parentInvocation)
- : super(parent, parentInvocation);
+ _FakeOAuth2Response_3(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
}
class _FakeResponse_4 extends _i1.SmartFake implements _i6.Response {
- _FakeResponse_4(Object parent, Invocation parentInvocation)
- : super(parent, parentInvocation);
+ _FakeResponse_4(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
}
class _FakeStreamedResponse_5 extends _i1.SmartFake
implements _i6.StreamedResponse {
- _FakeStreamedResponse_5(Object parent, Invocation parentInvocation)
- : super(parent, parentInvocation);
+ _FakeStreamedResponse_5(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
}
class _FakeBaseStorage_6 extends _i1.SmartFake implements _i7.BaseStorage {
- _FakeBaseStorage_6(Object parent, Invocation parentInvocation)
- : super(parent, parentInvocation);
+ _FakeBaseStorage_6(
+ Object parent,
+ Invocation parentInvocation,
+ ) : super(
+ parent,
+ parentInvocation,
+ );
}
/// A class which mocks [OAuth2Client].
///
/// See the documentation for Mockito's code generation for more information.
-class MockOAuth2Client extends _i1.Mock implements _i8.OAuth2Client {
+class MockOAuth2Client extends _i1.Mock implements _i4.OAuth2Client {
MockOAuth2Client() {
_i1.throwOnMissingStub(this);
}
@override
- String get redirectUri =>
- (super.noSuchMethod(Invocation.getter(#redirectUri), returnValue: '')
- as String);
+ String get redirectUri => (super.noSuchMethod(
+ Invocation.getter(#redirectUri),
+ returnValue: '',
+ ) as String);
@override
- set redirectUri(String? _redirectUri) =>
- super.noSuchMethod(Invocation.setter(#redirectUri, _redirectUri),
- returnValueForMissingStub: null);
+ set redirectUri(String? _redirectUri) => super.noSuchMethod(
+ Invocation.setter(
+ #redirectUri,
+ _redirectUri,
+ ),
+ returnValueForMissingStub: null,
+ );
@override
- String get customUriScheme =>
- (super.noSuchMethod(Invocation.getter(#customUriScheme), returnValue: '')
- as String);
+ String get customUriScheme => (super.noSuchMethod(
+ Invocation.getter(#customUriScheme),
+ returnValue: '',
+ ) as String);
@override
- set customUriScheme(String? _customUriScheme) =>
- super.noSuchMethod(Invocation.setter(#customUriScheme, _customUriScheme),
- returnValueForMissingStub: null);
+ set customUriScheme(String? _customUriScheme) => super.noSuchMethod(
+ Invocation.setter(
+ #customUriScheme,
+ _customUriScheme,
+ ),
+ returnValueForMissingStub: null,
+ );
@override
- String get tokenUrl =>
- (super.noSuchMethod(Invocation.getter(#tokenUrl), returnValue: '')
- as String);
+ String get tokenUrl => (super.noSuchMethod(
+ Invocation.getter(#tokenUrl),
+ returnValue: '',
+ ) as String);
@override
- set tokenUrl(String? _tokenUrl) =>
- super.noSuchMethod(Invocation.setter(#tokenUrl, _tokenUrl),
- returnValueForMissingStub: null);
+ set tokenUrl(String? _tokenUrl) => super.noSuchMethod(
+ Invocation.setter(
+ #tokenUrl,
+ _tokenUrl,
+ ),
+ returnValueForMissingStub: null,
+ );
@override
- set refreshUrl(String? _refreshUrl) =>
- super.noSuchMethod(Invocation.setter(#refreshUrl, _refreshUrl),
- returnValueForMissingStub: null);
+ set refreshUrl(String? _refreshUrl) => super.noSuchMethod(
+ Invocation.setter(
+ #refreshUrl,
+ _refreshUrl,
+ ),
+ returnValueForMissingStub: null,
+ );
@override
- set revokeUrl(String? _revokeUrl) =>
- super.noSuchMethod(Invocation.setter(#revokeUrl, _revokeUrl),
- returnValueForMissingStub: null);
+ set revokeUrl(String? _revokeUrl) => super.noSuchMethod(
+ Invocation.setter(
+ #revokeUrl,
+ _revokeUrl,
+ ),
+ returnValueForMissingStub: null,
+ );
@override
- String get authorizeUrl =>
- (super.noSuchMethod(Invocation.getter(#authorizeUrl), returnValue: '')
- as String);
+ String get authorizeUrl => (super.noSuchMethod(
+ Invocation.getter(#authorizeUrl),
+ returnValue: '',
+ ) as String);
@override
- set authorizeUrl(String? _authorizeUrl) =>
- super.noSuchMethod(Invocation.setter(#authorizeUrl, _authorizeUrl),
- returnValueForMissingStub: null);
+ set authorizeUrl(String? _authorizeUrl) => super.noSuchMethod(
+ Invocation.setter(
+ #authorizeUrl,
+ _authorizeUrl,
+ ),
+ returnValueForMissingStub: null,
+ );
@override
- String get scopeSeparator =>
- (super.noSuchMethod(Invocation.getter(#scopeSeparator), returnValue: '')
- as String);
+ String get scopeSeparator => (super.noSuchMethod(
+ Invocation.getter(#scopeSeparator),
+ returnValue: '',
+ ) as String);
@override
- set scopeSeparator(String? _scopeSeparator) =>
- super.noSuchMethod(Invocation.setter(#scopeSeparator, _scopeSeparator),
- returnValueForMissingStub: null);
+ set scopeSeparator(String? _scopeSeparator) => super.noSuchMethod(
+ Invocation.setter(
+ #scopeSeparator,
+ _scopeSeparator,
+ ),
+ returnValueForMissingStub: null,
+ );
@override
- _i2.BaseWebAuth get webAuthClient =>
- (super.noSuchMethod(Invocation.getter(#webAuthClient),
- returnValue:
- _FakeBaseWebAuth_0(this, Invocation.getter(#webAuthClient)))
- as _i2.BaseWebAuth);
+ _i2.BaseWebAuth get webAuthClient => (super.noSuchMethod(
+ Invocation.getter(#webAuthClient),
+ returnValue: _FakeBaseWebAuth_0(
+ this,
+ Invocation.getter(#webAuthClient),
+ ),
+ ) as _i2.BaseWebAuth);
@override
- set webAuthClient(_i2.BaseWebAuth? _webAuthClient) =>
- super.noSuchMethod(Invocation.setter(#webAuthClient, _webAuthClient),
- returnValueForMissingStub: null);
+ set webAuthClient(_i2.BaseWebAuth? _webAuthClient) => super.noSuchMethod(
+ Invocation.setter(
+ #webAuthClient,
+ _webAuthClient,
+ ),
+ returnValueForMissingStub: null,
+ );
@override
- _i8.CredentialsLocation get credentialsLocation => (super.noSuchMethod(
- Invocation.getter(#credentialsLocation),
- returnValue: _i8.CredentialsLocation.header) as _i8.CredentialsLocation);
+ _i4.CredentialsLocation get credentialsLocation => (super.noSuchMethod(
+ Invocation.getter(#credentialsLocation),
+ returnValue: _i4.CredentialsLocation.header,
+ ) as _i4.CredentialsLocation);
@override
- set credentialsLocation(_i8.CredentialsLocation? _credentialsLocation) =>
+ set credentialsLocation(_i4.CredentialsLocation? _credentialsLocation) =>
super.noSuchMethod(
- Invocation.setter(#credentialsLocation, _credentialsLocation),
- returnValueForMissingStub: null);
- @override
- _i9.Future<_i3.AccessTokenResponse> getTokenWithImplicitGrantFlow(
- {String? clientId,
- List? scopes,
- bool? enableState = true,
- String? state,
- dynamic httpClient,
- _i2.BaseWebAuth? webAuthClient,
- Map? webAuthOpts,
- Map? customParams}) =>
+ Invocation.setter(
+ #credentialsLocation,
+ _credentialsLocation,
+ ),
+ returnValueForMissingStub: null,
+ );
+ @override
+ _i8.Future<_i3.AccessTokenResponse> getTokenWithImplicitGrantFlow({
+ required String? clientId,
+ List? scopes,
+ bool? enableState = true,
+ String? state,
+ dynamic httpClient,
+ _i2.BaseWebAuth? webAuthClient,
+ Map? webAuthOpts,
+ Map? customParams,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#getTokenWithImplicitGrantFlow, [], {
+ Invocation.method(
+ #getTokenWithImplicitGrantFlow,
+ [],
+ {
#clientId: clientId,
#scopes: scopes,
#enableState: enableState,
@@ -161,39 +243,50 @@ class MockOAuth2Client extends _i1.Mock implements _i8.OAuth2Client {
#httpClient: httpClient,
#webAuthClient: webAuthClient,
#webAuthOpts: webAuthOpts,
- #customParams: customParams
- }),
- returnValue: _i9.Future<_i3.AccessTokenResponse>.value(
- _FakeAccessTokenResponse_1(
- this,
- Invocation.method(#getTokenWithImplicitGrantFlow, [], {
- #clientId: clientId,
- #scopes: scopes,
- #enableState: enableState,
- #state: state,
- #httpClient: httpClient,
- #webAuthClient: webAuthClient,
- #webAuthOpts: webAuthOpts,
- #customParams: customParams
- })))) as _i9.Future<_i3.AccessTokenResponse>);
- @override
- _i9.Future<_i3.AccessTokenResponse> getTokenWithAuthCodeFlow(
- {String? clientId,
- List? scopes,
- String? clientSecret,
- bool? enablePKCE = true,
- bool? enableState = true,
- String? state,
- String? codeVerifier,
- Function? afterAuthorizationCodeCb,
- Map? authCodeParams,
- Map? accessTokenParams,
- Map? accessTokenHeaders,
- dynamic httpClient,
- _i2.BaseWebAuth? webAuthClient,
- Map? webAuthOpts}) =>
+ #customParams: customParams,
+ },
+ ),
+ returnValue: _i8.Future<_i3.AccessTokenResponse>.value(
+ _FakeAccessTokenResponse_1(
+ this,
+ Invocation.method(
+ #getTokenWithImplicitGrantFlow,
+ [],
+ {
+ #clientId: clientId,
+ #scopes: scopes,
+ #enableState: enableState,
+ #state: state,
+ #httpClient: httpClient,
+ #webAuthClient: webAuthClient,
+ #webAuthOpts: webAuthOpts,
+ #customParams: customParams,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i3.AccessTokenResponse>);
+ @override
+ _i8.Future<_i3.AccessTokenResponse> getTokenWithAuthCodeFlow({
+ required String? clientId,
+ List? scopes,
+ String? clientSecret,
+ bool? enablePKCE = true,
+ bool? enableState = true,
+ String? state,
+ String? codeVerifier,
+ Function? afterAuthorizationCodeCb,
+ Map? authCodeParams,
+ Map? accessTokenParams,
+ Map? accessTokenHeaders,
+ dynamic httpClient,
+ _i2.BaseWebAuth? webAuthClient,
+ Map? webAuthOpts,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#getTokenWithAuthCodeFlow, [], {
+ Invocation.method(
+ #getTokenWithAuthCodeFlow,
+ [],
+ {
#clientId: clientId,
#scopes: scopes,
#clientSecret: clientSecret,
@@ -207,64 +300,86 @@ class MockOAuth2Client extends _i1.Mock implements _i8.OAuth2Client {
#accessTokenHeaders: accessTokenHeaders,
#httpClient: httpClient,
#webAuthClient: webAuthClient,
- #webAuthOpts: webAuthOpts
- }),
- returnValue: _i9.Future<_i3.AccessTokenResponse>.value(
- _FakeAccessTokenResponse_1(
- this,
- Invocation.method(#getTokenWithAuthCodeFlow, [], {
- #clientId: clientId,
- #scopes: scopes,
- #clientSecret: clientSecret,
- #enablePKCE: enablePKCE,
- #enableState: enableState,
- #state: state,
- #codeVerifier: codeVerifier,
- #afterAuthorizationCodeCb: afterAuthorizationCodeCb,
- #authCodeParams: authCodeParams,
- #accessTokenParams: accessTokenParams,
- #accessTokenHeaders: accessTokenHeaders,
- #httpClient: httpClient,
- #webAuthClient: webAuthClient,
- #webAuthOpts: webAuthOpts
- })))) as _i9.Future<_i3.AccessTokenResponse>);
- @override
- _i9.Future<_i3.AccessTokenResponse> getTokenWithClientCredentialsFlow(
- {String? clientId,
- String? clientSecret,
- List? scopes,
- Map? customHeaders,
- dynamic httpClient}) =>
+ #webAuthOpts: webAuthOpts,
+ },
+ ),
+ returnValue: _i8.Future<_i3.AccessTokenResponse>.value(
+ _FakeAccessTokenResponse_1(
+ this,
+ Invocation.method(
+ #getTokenWithAuthCodeFlow,
+ [],
+ {
+ #clientId: clientId,
+ #scopes: scopes,
+ #clientSecret: clientSecret,
+ #enablePKCE: enablePKCE,
+ #enableState: enableState,
+ #state: state,
+ #codeVerifier: codeVerifier,
+ #afterAuthorizationCodeCb: afterAuthorizationCodeCb,
+ #authCodeParams: authCodeParams,
+ #accessTokenParams: accessTokenParams,
+ #accessTokenHeaders: accessTokenHeaders,
+ #httpClient: httpClient,
+ #webAuthClient: webAuthClient,
+ #webAuthOpts: webAuthOpts,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i3.AccessTokenResponse>);
+ @override
+ _i8.Future<_i3.AccessTokenResponse> getTokenWithClientCredentialsFlow({
+ required String? clientId,
+ required String? clientSecret,
+ List? scopes,
+ Map? customHeaders,
+ dynamic httpClient,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#getTokenWithClientCredentialsFlow, [], {
+ Invocation.method(
+ #getTokenWithClientCredentialsFlow,
+ [],
+ {
#clientId: clientId,
#clientSecret: clientSecret,
#scopes: scopes,
#customHeaders: customHeaders,
- #httpClient: httpClient
- }),
- returnValue: _i9.Future<_i3.AccessTokenResponse>.value(
- _FakeAccessTokenResponse_1(
- this,
- Invocation.method(#getTokenWithClientCredentialsFlow, [], {
- #clientId: clientId,
- #clientSecret: clientSecret,
- #scopes: scopes,
- #customHeaders: customHeaders,
- #httpClient: httpClient
- })))) as _i9.Future<_i3.AccessTokenResponse>);
- @override
- _i9.Future<_i4.AuthorizationResponse> requestAuthorization(
- {String? clientId,
- List? scopes,
- String? codeChallenge,
- bool? enableState = true,
- String? state,
- Map? customParams,
- _i2.BaseWebAuth? webAuthClient,
- Map? webAuthOpts}) =>
+ #httpClient: httpClient,
+ },
+ ),
+ returnValue: _i8.Future<_i3.AccessTokenResponse>.value(
+ _FakeAccessTokenResponse_1(
+ this,
+ Invocation.method(
+ #getTokenWithClientCredentialsFlow,
+ [],
+ {
+ #clientId: clientId,
+ #clientSecret: clientSecret,
+ #scopes: scopes,
+ #customHeaders: customHeaders,
+ #httpClient: httpClient,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i3.AccessTokenResponse>);
+ @override
+ _i8.Future<_i4.AuthorizationWrapper> requestAuthorization({
+ required String? clientId,
+ List? scopes,
+ String? codeChallenge,
+ bool? enableState = true,
+ String? state,
+ Map? customParams,
+ _i2.BaseWebAuth? webAuthClient,
+ Map? webAuthOpts,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#requestAuthorization, [], {
+ Invocation.method(
+ #requestAuthorization,
+ [],
+ {
#clientId: clientId,
#scopes: scopes,
#codeChallenge: codeChallenge,
@@ -272,33 +387,44 @@ class MockOAuth2Client extends _i1.Mock implements _i8.OAuth2Client {
#state: state,
#customParams: customParams,
#webAuthClient: webAuthClient,
- #webAuthOpts: webAuthOpts
- }),
- returnValue: _i9.Future<_i4.AuthorizationResponse>.value(
- _FakeAuthorizationResponse_2(
- this,
- Invocation.method(#requestAuthorization, [], {
- #clientId: clientId,
- #scopes: scopes,
- #codeChallenge: codeChallenge,
- #enableState: enableState,
- #state: state,
- #customParams: customParams,
- #webAuthClient: webAuthClient,
- #webAuthOpts: webAuthOpts
- })))) as _i9.Future<_i4.AuthorizationResponse>);
- @override
- _i9.Future<_i3.AccessTokenResponse> requestAccessToken(
- {String? code,
- String? clientId,
- String? clientSecret,
- String? codeVerifier,
- List? scopes,
- Map? customParams,
- Map? customHeaders,
- dynamic httpClient}) =>
+ #webAuthOpts: webAuthOpts,
+ },
+ ),
+ returnValue: _i8.Future<_i4.AuthorizationWrapper>.value(
+ _FakeAuthorizationWrapper_2(
+ this,
+ Invocation.method(
+ #requestAuthorization,
+ [],
+ {
+ #clientId: clientId,
+ #scopes: scopes,
+ #codeChallenge: codeChallenge,
+ #enableState: enableState,
+ #state: state,
+ #customParams: customParams,
+ #webAuthClient: webAuthClient,
+ #webAuthOpts: webAuthOpts,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i4.AuthorizationWrapper>);
+ @override
+ _i8.Future<_i3.AccessTokenResponse> requestAccessToken({
+ required String? code,
+ required String? clientId,
+ String? clientSecret,
+ String? codeVerifier,
+ List? scopes,
+ Map? customParams,
+ Map? customHeaders,
+ dynamic httpClient,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#requestAccessToken, [], {
+ Invocation.method(
+ #requestAccessToken,
+ [],
+ {
#code: code,
#clientId: clientId,
#clientSecret: clientSecret,
@@ -306,98 +432,168 @@ class MockOAuth2Client extends _i1.Mock implements _i8.OAuth2Client {
#scopes: scopes,
#customParams: customParams,
#customHeaders: customHeaders,
- #httpClient: httpClient
- }),
- returnValue: _i9.Future<_i3.AccessTokenResponse>.value(
- _FakeAccessTokenResponse_1(
- this,
- Invocation.method(#requestAccessToken, [], {
- #code: code,
- #clientId: clientId,
- #clientSecret: clientSecret,
- #codeVerifier: codeVerifier,
- #scopes: scopes,
- #customParams: customParams,
- #customHeaders: customHeaders,
- #httpClient: httpClient
- })))) as _i9.Future<_i3.AccessTokenResponse>);
- @override
- _i9.Future<_i3.AccessTokenResponse> refreshToken(String? refreshToken,
- {dynamic httpClient,
- String? clientId,
- String? clientSecret,
- List? scopes}) =>
+ #httpClient: httpClient,
+ },
+ ),
+ returnValue: _i8.Future<_i3.AccessTokenResponse>.value(
+ _FakeAccessTokenResponse_1(
+ this,
+ Invocation.method(
+ #requestAccessToken,
+ [],
+ {
+ #code: code,
+ #clientId: clientId,
+ #clientSecret: clientSecret,
+ #codeVerifier: codeVerifier,
+ #scopes: scopes,
+ #customParams: customParams,
+ #customHeaders: customHeaders,
+ #httpClient: httpClient,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i3.AccessTokenResponse>);
+ @override
+ _i8.Future<_i3.AccessTokenResponse> refreshToken(
+ String? refreshToken, {
+ dynamic httpClient,
+ required String? clientId,
+ String? clientSecret,
+ List? scopes,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#refreshToken, [
- refreshToken
- ], {
+ Invocation.method(
+ #refreshToken,
+ [refreshToken],
+ {
#httpClient: httpClient,
#clientId: clientId,
#clientSecret: clientSecret,
- #scopes: scopes
- }),
- returnValue: _i9.Future<_i3.AccessTokenResponse>.value(
- _FakeAccessTokenResponse_1(
- this,
- Invocation.method(#refreshToken, [
- refreshToken
- ], {
- #httpClient: httpClient,
- #clientId: clientId,
- #clientSecret: clientSecret,
- #scopes: scopes
- })))) as _i9.Future<_i3.AccessTokenResponse>);
- @override
- _i9.Future<_i5.OAuth2Response> revokeToken(_i3.AccessTokenResponse? tknResp,
- {String? clientId, String? clientSecret, dynamic httpClient}) =>
- (super.noSuchMethod(Invocation.method(#revokeToken, [tknResp], {#clientId: clientId, #clientSecret: clientSecret, #httpClient: httpClient}),
- returnValue: _i9.Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3(
- this,
- Invocation.method(#revokeToken, [
- tknResp
- ], {
- #clientId: clientId,
- #clientSecret: clientSecret,
- #httpClient: httpClient
- })))) as _i9.Future<_i5.OAuth2Response>);
- @override
- _i9.Future<_i5.OAuth2Response> revokeAccessToken(_i3.AccessTokenResponse? tknResp,
- {String? clientId, String? clientSecret, dynamic httpClient}) =>
- (super.noSuchMethod(Invocation.method(#revokeAccessToken, [tknResp], {#clientId: clientId, #clientSecret: clientSecret, #httpClient: httpClient}),
- returnValue: _i9.Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3(
- this,
- Invocation.method(#revokeAccessToken, [
- tknResp
- ], {
- #clientId: clientId,
- #clientSecret: clientSecret,
- #httpClient: httpClient
- })))) as _i9.Future<_i5.OAuth2Response>);
- @override
- _i9.Future<_i5.OAuth2Response> revokeRefreshToken(_i3.AccessTokenResponse? tknResp,
- {String? clientId, String? clientSecret, dynamic httpClient}) =>
- (super.noSuchMethod(Invocation.method(#revokeRefreshToken, [tknResp], {#clientId: clientId, #clientSecret: clientSecret, #httpClient: httpClient}),
- returnValue: _i9.Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3(
- this,
- Invocation.method(#revokeRefreshToken, [
- tknResp
- ], {
- #clientId: clientId,
- #clientSecret: clientSecret,
- #httpClient: httpClient
- })))) as _i9.Future<_i5.OAuth2Response>);
- @override
- String getAuthorizeUrl(
- {String? clientId,
- String? responseType = r'code',
- String? redirectUri,
- List? scopes,
- bool? enableState = true,
- String? state,
- String? codeChallenge,
- Map? customParams}) =>
+ #scopes: scopes,
+ },
+ ),
+ returnValue: _i8.Future<_i3.AccessTokenResponse>.value(
+ _FakeAccessTokenResponse_1(
+ this,
+ Invocation.method(
+ #refreshToken,
+ [refreshToken],
+ {
+ #httpClient: httpClient,
+ #clientId: clientId,
+ #clientSecret: clientSecret,
+ #scopes: scopes,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i3.AccessTokenResponse>);
+ @override
+ _i8.Future<_i5.OAuth2Response> revokeToken(
+ _i3.AccessTokenResponse? tknResp, {
+ String? clientId,
+ String? clientSecret,
+ dynamic httpClient,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#getAuthorizeUrl, [], {
+ Invocation.method(
+ #revokeToken,
+ [tknResp],
+ {
+ #clientId: clientId,
+ #clientSecret: clientSecret,
+ #httpClient: httpClient,
+ },
+ ),
+ returnValue: _i8.Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3(
+ this,
+ Invocation.method(
+ #revokeToken,
+ [tknResp],
+ {
+ #clientId: clientId,
+ #clientSecret: clientSecret,
+ #httpClient: httpClient,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i5.OAuth2Response>);
+ @override
+ _i8.Future<_i5.OAuth2Response> revokeAccessToken(
+ _i3.AccessTokenResponse? tknResp, {
+ String? clientId,
+ String? clientSecret,
+ dynamic httpClient,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #revokeAccessToken,
+ [tknResp],
+ {
+ #clientId: clientId,
+ #clientSecret: clientSecret,
+ #httpClient: httpClient,
+ },
+ ),
+ returnValue: _i8.Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3(
+ this,
+ Invocation.method(
+ #revokeAccessToken,
+ [tknResp],
+ {
+ #clientId: clientId,
+ #clientSecret: clientSecret,
+ #httpClient: httpClient,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i5.OAuth2Response>);
+ @override
+ _i8.Future<_i5.OAuth2Response> revokeRefreshToken(
+ _i3.AccessTokenResponse? tknResp, {
+ String? clientId,
+ String? clientSecret,
+ dynamic httpClient,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #revokeRefreshToken,
+ [tknResp],
+ {
+ #clientId: clientId,
+ #clientSecret: clientSecret,
+ #httpClient: httpClient,
+ },
+ ),
+ returnValue: _i8.Future<_i5.OAuth2Response>.value(_FakeOAuth2Response_3(
+ this,
+ Invocation.method(
+ #revokeRefreshToken,
+ [tknResp],
+ {
+ #clientId: clientId,
+ #clientSecret: clientSecret,
+ #httpClient: httpClient,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i5.OAuth2Response>);
+ @override
+ String getAuthorizeUrl({
+ required String? clientId,
+ String? responseType = r'code',
+ String? redirectUri,
+ List? scopes,
+ bool? enableState = true,
+ String? state,
+ String? codeChallenge,
+ Map? customParams,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #getAuthorizeUrl,
+ [],
+ {
#clientId: clientId,
#responseType: responseType,
#redirectUri: redirectUri,
@@ -405,53 +601,85 @@ class MockOAuth2Client extends _i1.Mock implements _i8.OAuth2Client {
#enableState: enableState,
#state: state,
#codeChallenge: codeChallenge,
- #customParams: customParams
- }),
- returnValue: '') as String);
- @override
- Map getTokenUrlParams(
- {String? code,
- String? redirectUri,
- String? codeVerifier,
- Map? customParams}) =>
+ #customParams: customParams,
+ },
+ ),
+ returnValue: '',
+ ) as String);
+ @override
+ Map getTokenUrlParams({
+ required String? code,
+ String? redirectUri,
+ String? codeVerifier,
+ Map? customParams,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#getTokenUrlParams, [], {
+ Invocation.method(
+ #getTokenUrlParams,
+ [],
+ {
#code: code,
#redirectUri: redirectUri,
#codeVerifier: codeVerifier,
- #customParams: customParams
- }),
- returnValue: {}) as Map);
+ #customParams: customParams,
+ },
+ ),
+ returnValue: {},
+ ) as Map);
@override
- Map getAuthorizationHeader(
- {String? clientId, String? clientSecret}) =>
+ Map getAuthorizationHeader({
+ required String? clientId,
+ String? clientSecret,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#getAuthorizationHeader, [],
- {#clientId: clientId, #clientSecret: clientSecret}),
- returnValue: {}) as Map);
+ Invocation.method(
+ #getAuthorizationHeader,
+ [],
+ {
+ #clientId: clientId,
+ #clientSecret: clientSecret,
+ },
+ ),
+ returnValue: {},
+ ) as Map);
@override
- Map getRefreshUrlParams({String? refreshToken}) =>
+ Map getRefreshUrlParams({required String? refreshToken}) =>
(super.noSuchMethod(
- Invocation.method(
- #getRefreshUrlParams, [], {#refreshToken: refreshToken}),
- returnValue: {}) as Map);
+ Invocation.method(
+ #getRefreshUrlParams,
+ [],
+ {#refreshToken: refreshToken},
+ ),
+ returnValue: {},
+ ) as Map);
@override
- _i3.AccessTokenResponse http2TokenResponse(_i6.Response? response,
- {List? requestedScopes}) =>
+ _i3.AccessTokenResponse http2TokenResponse(
+ _i6.Response? response, {
+ List? requestedScopes,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#http2TokenResponse, [response],
- {#requestedScopes: requestedScopes}),
- returnValue: _FakeAccessTokenResponse_1(
- this,
- Invocation.method(#http2TokenResponse, [
- response
- ], {
- #requestedScopes: requestedScopes
- }))) as _i3.AccessTokenResponse);
- @override
- String serializeScopes(List? scopes) =>
- (super.noSuchMethod(Invocation.method(#serializeScopes, [scopes]),
- returnValue: '') as String);
+ Invocation.method(
+ #http2TokenResponse,
+ [response],
+ {#requestedScopes: requestedScopes},
+ ),
+ returnValue: _FakeAccessTokenResponse_1(
+ this,
+ Invocation.method(
+ #http2TokenResponse,
+ [response],
+ {#requestedScopes: requestedScopes},
+ ),
+ ),
+ ) as _i3.AccessTokenResponse);
+ @override
+ String serializeScopes(List? scopes) => (super.noSuchMethod(
+ Invocation.method(
+ #serializeScopes,
+ [scopes],
+ ),
+ returnValue: '',
+ ) as String);
}
/// A class which mocks [Client].
@@ -463,165 +691,324 @@ class MockClient extends _i1.Mock implements _i6.Client {
}
@override
- _i9.Future<_i6.Response> head(Uri? url, {Map? headers}) =>
- (super.noSuchMethod(Invocation.method(#head, [url], {#headers: headers}),
- returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4(
- this, Invocation.method(#head, [url], {#headers: headers}))))
- as _i9.Future<_i6.Response>);
- @override
- _i9.Future<_i6.Response> get(Uri? url, {Map? headers}) =>
- (super.noSuchMethod(Invocation.method(#get, [url], {#headers: headers}),
- returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4(
- this, Invocation.method(#get, [url], {#headers: headers}))))
- as _i9.Future<_i6.Response>);
- @override
- _i9.Future<_i6.Response> post(Uri? url,
- {Map? headers,
- Object? body,
- _i10.Encoding? encoding}) =>
- (super
- .noSuchMethod(Invocation.method(#post, [url], {#headers: headers, #body: body, #encoding: encoding}),
- returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4(
- this,
- Invocation.method(#post, [
- url
- ], {
- #headers: headers,
- #body: body,
- #encoding: encoding
- })))) as _i9.Future<_i6.Response>);
- @override
- _i9.Future<_i6.Response> put(Uri? url,
- {Map? headers,
- Object? body,
- _i10.Encoding? encoding}) =>
- (super
- .noSuchMethod(Invocation.method(#put, [url], {#headers: headers, #body: body, #encoding: encoding}),
- returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4(
- this,
- Invocation.method(#put, [
- url
- ], {
- #headers: headers,
- #body: body,
- #encoding: encoding
- })))) as _i9.Future<_i6.Response>);
- @override
- _i9.Future<_i6.Response> patch(Uri? url,
- {Map? headers,
- Object? body,
- _i10.Encoding? encoding}) =>
- (super
- .noSuchMethod(Invocation.method(#patch, [url], {#headers: headers, #body: body, #encoding: encoding}),
- returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4(
- this,
- Invocation.method(#patch, [
- url
- ], {
- #headers: headers,
- #body: body,
- #encoding: encoding
- })))) as _i9.Future<_i6.Response>);
- @override
- _i9.Future<_i6.Response> delete(Uri? url,
- {Map? headers,
- Object? body,
- _i10.Encoding? encoding}) =>
- (super
- .noSuchMethod(Invocation.method(#delete, [url], {#headers: headers, #body: body, #encoding: encoding}),
- returnValue: _i9.Future<_i6.Response>.value(_FakeResponse_4(
- this,
- Invocation.method(#delete, [
- url
- ], {
- #headers: headers,
- #body: body,
- #encoding: encoding
- })))) as _i9.Future<_i6.Response>);
- @override
- _i9.Future read(Uri? url, {Map? headers}) =>
- (super.noSuchMethod(Invocation.method(#read, [url], {#headers: headers}),
- returnValue: _i9.Future.value('')) as _i9.Future);
- @override
- _i9.Future<_i11.Uint8List> readBytes(Uri? url,
- {Map? headers}) =>
+ _i8.Future<_i6.Response> head(
+ Uri? url, {
+ Map? headers,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #head,
+ [url],
+ {#headers: headers},
+ ),
+ returnValue: _i8.Future<_i6.Response>.value(_FakeResponse_4(
+ this,
+ Invocation.method(
+ #head,
+ [url],
+ {#headers: headers},
+ ),
+ )),
+ ) as _i8.Future<_i6.Response>);
+ @override
+ _i8.Future<_i6.Response> get(
+ Uri? url, {
+ Map? headers,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #get,
+ [url],
+ {#headers: headers},
+ ),
+ returnValue: _i8.Future<_i6.Response>.value(_FakeResponse_4(
+ this,
+ Invocation.method(
+ #get,
+ [url],
+ {#headers: headers},
+ ),
+ )),
+ ) as _i8.Future<_i6.Response>);
+ @override
+ _i8.Future<_i6.Response> post(
+ Uri? url, {
+ Map? headers,
+ Object? body,
+ _i9.Encoding? encoding,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #post,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ returnValue: _i8.Future<_i6.Response>.value(_FakeResponse_4(
+ this,
+ Invocation.method(
+ #post,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i6.Response>);
+ @override
+ _i8.Future<_i6.Response> put(
+ Uri? url, {
+ Map? headers,
+ Object? body,
+ _i9.Encoding? encoding,
+ }) =>
(super.noSuchMethod(
- Invocation.method(#readBytes, [url], {#headers: headers}),
- returnValue: _i9.Future<_i11.Uint8List>.value(_i11.Uint8List(0)))
- as _i9.Future<_i11.Uint8List>);
- @override
- _i9.Future<_i6.StreamedResponse> send(_i6.BaseRequest? request) =>
- (super.noSuchMethod(Invocation.method(#send, [request]),
- returnValue: _i9.Future<_i6.StreamedResponse>.value(
- _FakeStreamedResponse_5(
- this, Invocation.method(#send, [request]))))
- as _i9.Future<_i6.StreamedResponse>);
- @override
- void close() => super.noSuchMethod(Invocation.method(#close, []),
- returnValueForMissingStub: null);
+ Invocation.method(
+ #put,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ returnValue: _i8.Future<_i6.Response>.value(_FakeResponse_4(
+ this,
+ Invocation.method(
+ #put,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i6.Response>);
+ @override
+ _i8.Future<_i6.Response> patch(
+ Uri? url, {
+ Map? headers,
+ Object? body,
+ _i9.Encoding? encoding,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #patch,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ returnValue: _i8.Future<_i6.Response>.value(_FakeResponse_4(
+ this,
+ Invocation.method(
+ #patch,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i6.Response>);
+ @override
+ _i8.Future<_i6.Response> delete(
+ Uri? url, {
+ Map? headers,
+ Object? body,
+ _i9.Encoding? encoding,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #delete,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ returnValue: _i8.Future<_i6.Response>.value(_FakeResponse_4(
+ this,
+ Invocation.method(
+ #delete,
+ [url],
+ {
+ #headers: headers,
+ #body: body,
+ #encoding: encoding,
+ },
+ ),
+ )),
+ ) as _i8.Future<_i6.Response>);
+ @override
+ _i8.Future read(
+ Uri? url, {
+ Map? headers,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #read,
+ [url],
+ {#headers: headers},
+ ),
+ returnValue: _i8.Future.value(''),
+ ) as _i8.Future);
+ @override
+ _i8.Future<_i10.Uint8List> readBytes(
+ Uri? url, {
+ Map? headers,
+ }) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #readBytes,
+ [url],
+ {#headers: headers},
+ ),
+ returnValue: _i8.Future<_i10.Uint8List>.value(_i10.Uint8List(0)),
+ ) as _i8.Future<_i10.Uint8List>);
+ @override
+ _i8.Future<_i6.StreamedResponse> send(_i6.BaseRequest? request) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #send,
+ [request],
+ ),
+ returnValue:
+ _i8.Future<_i6.StreamedResponse>.value(_FakeStreamedResponse_5(
+ this,
+ Invocation.method(
+ #send,
+ [request],
+ ),
+ )),
+ ) as _i8.Future<_i6.StreamedResponse>);
+ @override
+ void close() => super.noSuchMethod(
+ Invocation.method(
+ #close,
+ [],
+ ),
+ returnValueForMissingStub: null,
+ );
}
/// A class which mocks [TokenStorage].
///
/// See the documentation for Mockito's code generation for more information.
-class MockTokenStorage extends _i1.Mock implements _i12.TokenStorage {
+class MockTokenStorage extends _i1.Mock implements _i11.TokenStorage {
MockTokenStorage() {
_i1.throwOnMissingStub(this);
}
@override
- String get key =>
- (super.noSuchMethod(Invocation.getter(#key), returnValue: '') as String);
+ String get key => (super.noSuchMethod(
+ Invocation.getter(#key),
+ returnValue: '',
+ ) as String);
@override
- set key(String? _key) => super.noSuchMethod(Invocation.setter(#key, _key),
- returnValueForMissingStub: null);
+ set key(String? _key) => super.noSuchMethod(
+ Invocation.setter(
+ #key,
+ _key,
+ ),
+ returnValueForMissingStub: null,
+ );
@override
_i7.BaseStorage get storage => (super.noSuchMethod(
+ Invocation.getter(#storage),
+ returnValue: _FakeBaseStorage_6(
+ this,
Invocation.getter(#storage),
- returnValue: _FakeBaseStorage_6(this, Invocation.getter(#storage)))
- as _i7.BaseStorage);
+ ),
+ ) as _i7.BaseStorage);
@override
- set storage(_i7.BaseStorage? _storage) =>
- super.noSuchMethod(Invocation.setter(#storage, _storage),
- returnValueForMissingStub: null);
+ set storage(_i7.BaseStorage? _storage) => super.noSuchMethod(
+ Invocation.setter(
+ #storage,
+ _storage,
+ ),
+ returnValueForMissingStub: null,
+ );
@override
- _i9.Future<_i3.AccessTokenResponse?> getToken(List? scopes) =>
- (super.noSuchMethod(Invocation.method(#getToken, [scopes]),
- returnValue: _i9.Future<_i3.AccessTokenResponse?>.value())
- as _i9.Future<_i3.AccessTokenResponse?>);
+ _i8.Future<_i3.AccessTokenResponse?> getToken(List? scopes) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #getToken,
+ [scopes],
+ ),
+ returnValue: _i8.Future<_i3.AccessTokenResponse?>.value(),
+ ) as _i8.Future<_i3.AccessTokenResponse?>);
@override
- _i9.Future addToken(_i3.AccessTokenResponse? tknResp) =>
- (super.noSuchMethod(Invocation.method(#addToken, [tknResp]),
- returnValue: _i9.Future.value(),
- returnValueForMissingStub: _i9.Future.value())
- as _i9.Future);
+ _i8.Future addToken(_i3.AccessTokenResponse? tknResp) =>
+ (super.noSuchMethod(
+ Invocation.method(
+ #addToken,
+ [tknResp],
+ ),
+ returnValue: _i8.Future.value(),
+ returnValueForMissingStub: _i8.Future.value(),
+ ) as _i8.Future);
@override
- _i9.Future