OAuthCredentials constructor
Create new OAuthCredentials.
clientId
Optional. Set the GoogleAPIclientId
used for auth flows. RequiresclientSecret
also be provided if set.clientSecret
Optional. Corresponding secret for providedclientId
.dio
Optional. Connection pooling with an active session.options
Optional. Modify the session with Dio BaseOptions.proxies
Optional. 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;
};
}
}