oauth_chopper 1.1.0 copy "oauth_chopper: ^1.1.0" to clipboard
oauth_chopper: ^1.1.0 copied to clipboard

Add and manage OAuth2 authentication for your Chopper client.

example/oauth_chopper_example.dart

// ignore because its a example.
// ignore_for_file: unused_local_variable, prefer_const_declarations,
// ignore_for_file: prefer_const_constructors

import 'package:chopper/chopper.dart';
import 'package:oauth_chopper/oauth_chopper.dart';

void main() {
  final authorizationEndpoint = Uri.parse('https://example.com/oauth');
  final identifier = 'id';
  final secret = 'secret';

  /// Create OAuthChopper instance.
  final oauthChopper = OAuthChopper(
    authorizationEndpoint: authorizationEndpoint,
    identifier: identifier,
    secret: secret,
  );

  /// Add the oauth_chopper interceptor to the chopper client.
  final chopperClient = ChopperClient(
    baseUrl: Uri.parse('https://example.com'),
    interceptors: [
      oauthChopper.interceptor(),
    ],
  );

  /// Request grant
  oauthChopper.requestGrant(
    ResourceOwnerPasswordGrant(
      username: 'username',
      password: 'password',
    ),
  );
}
2
likes
160
pub points
58%
popularity

Publisher

verified publisherdutchcodingcompany.com

Add and manage OAuth2 authentication for your Chopper client.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

chopper, http, http_parser, oauth2

More

Packages that depend on oauth_chopper