OAuthCredentials constructor

OAuthCredentials({
  1. required String clientId,
  2. required String clientSecret,
  3. Dio? dio,
  4. BaseOptions? options,
  5. Map<String, String>? proxies,
})

Create new OAuthCredentials.

  • clientId Optional. Set the GoogleAPI clientId used for auth flows. Requires clientSecret also be provided if set.
  • clientSecret Optional. Corresponding secret for provided clientId.
  • 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;
    };
  }
}