OAuthCredentials constructor
OAuthCredentials({})
Create new OAuthCredentials.
clientIdOptional. Set the GoogleAPIclientIdused for auth flows. RequiresclientSecretalso be provided if set.clientSecretOptional. Corresponding secret for providedclientId.dioOptional. Connection pooling with an active session.optionsOptional. Modify the session with DioBaseOptions.proxiesOptional. Modify the session with proxy parameters.
Implementation
OAuthCredentials({
required String clientId,
required String clientSecret,
Dio? dio,
BaseOptions? options,
Map<String, String>? proxies,
}) : super(clientId, clientSecret) {
_dio = dio ?? Dio(options ?? BaseOptions());
if (proxies != null && proxies.isNotEmpty) {
(_dio.httpClientAdapter as IOHttpClientAdapter).createHttpClient = () {
final client = HttpClient();
client.findProxy = (uri) {
if (uri.scheme == 'http' && proxies.containsKey('http')) {
return "PROXY ${proxies['http']}";
} else if (uri.scheme == 'https' && proxies.containsKey('https')) {
return "PROXY ${proxies['https']}";
}
return 'DIRECT';
};
client.badCertificateCallback = (cert, host, port) => true;
return client;
};
}
}