oauth1 1.0.3

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 85

OAuth1 #

Build Status

"RFC 5849: The OAuth 1.0 Protocol" client implementation for dart

Usage #

Add to pubspec.yaml:

dependencies:
  oauth1: ^1.0.1

Please use like below.

import 'dart:io';
import 'package:oauth1/oauth1.dart' as oauth1;

void main() {
  // define platform (server)
  var platform = new oauth1.Platform(
      'https://api.twitter.com/oauth/request_token', // temporary credentials request
      'https://api.twitter.com/oauth/authorize',     // resource owner authorization
      'https://api.twitter.com/oauth/access_token',  // token credentials request
      oauth1.SignatureMethods.HMAC_SHA1              // signature method
      );

  // define client credentials (consumer keys)
  const String apiKey = 'LLDeVY0ySvjoOVmJ2XgBItvTV';
  const String apiSecret = 'JmEpkWXXmY7BYoQor5AyR84BD2BiN47GIBUPXn3bopZqodJ0MV';
  var clientCredentials = new oauth1.ClientCredentials(apiKey, apiSecret);

  // create Authorization object with client credentials and platform definition
  var auth = new oauth1.Authorization(clientCredentials, platform);

  // request temporary credentials (request tokens)
  auth.requestTemporaryCredentials('oob').then((res) {
    // redirect to authorization page
    print("Open with your browser: ${auth.getResourceOwnerAuthorizationURI(res.credentials.token)}");

    // get verifier (PIN)
    stdout.write("PIN: ");
    String verifier = stdin.readLineSync();

    // request token credentials (access tokens)
    return auth.requestTokenCredentials(res.credentials, verifier);
  }).then((res) {
    // yeah, you got token credentials
    // create Client object
    var client = new oauth1.Client(platform.signatureMethod, clientCredentials, res.credentials);

    // now you can access to protected resources via client
    client.get('https://api.twitter.com/1.1/statuses/home_timeline.json?count=1').then((res) {
      print(res.body);
    });

    // NOTE: you can get optional values from AuthorizationResponse object
    print("Your screen name is " + res.optionalParameters['screen_name']);
  });
}

In addition, You should save and load the granted token credentials from your drive. Of cource, you don't need to authorize when you did it.

1.0.3 #

  • Confirm compatibility with package http 0.12.0

1.0.2 #

  • Further cleanup for Dart 2 support

1.0.1 #

  • Support Dart 2

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  oauth1: ^1.0.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:oauth1/oauth1.dart';
  
Version Uploaded Documentation Archive
1.0.4 Apr 7, 2019 Go to the documentation of oauth1 1.0.4 Download oauth1 1.0.4 archive
1.0.3 Sep 30, 2018 Go to the documentation of oauth1 1.0.3 Download oauth1 1.0.3 archive
1.0.2 Aug 11, 2018 Go to the documentation of oauth1 1.0.2 Download oauth1 1.0.2 archive
1.0.1 Jul 29, 2018 Go to the documentation of oauth1 1.0.1 Download oauth1 1.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
79
Health:
Code health derived from static analysis. [more]
92
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
85
Learn more about scoring.

We analyzed this package on May 30, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.1
  • pana: 0.12.17

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:oauth1/oauth1.dart.

Health suggestions

Fix lib/src/authorization.dart. (-2.48 points)

Analysis of lib/src/authorization.dart reported 5 hints:

line 12 col 1: Prefer using /// for doc comments.

line 24 col 3: Prefer using /// for doc comments.

line 33 col 3: Prefer using /// for doc comments.

line 69 col 3: Prefer using /// for doc comments.

line 77 col 3: Prefer using /// for doc comments.

Fix lib/src/authorization_header.dart. (-1.49 points)

Analysis of lib/src/authorization_header.dart reported 3 hints:

line 9 col 1: Prefer using /// for doc comments.

line 25 col 3: Prefer using /// for doc comments.

line 64 col 3: Prefer using /// for doc comments.

Fix lib/src/client.dart. (-1 points)

Analysis of lib/src/client.dart reported 2 hints:

line 11 col 1: Prefer using /// for doc comments.

line 23 col 3: Prefer using /// for doc comments.

Fix additional 6 files with analysis or formatting issues. (-3 points)

Additional issues in the following files:

  • lib/src/signature_method.dart (2 hints)
  • lib/src/authorization_header_builder.dart (1 hint)
  • lib/src/client_credentials.dart (1 hint)
  • lib/src/credentials.dart (1 hint)
  • lib/src/platform.dart (1 hint)
  • lib/src/authorization_response.dart (Run dartfmt to format lib/src/authorization_response.dart.)

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and oauth1.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.58.0 <3.0.0
crypto ^2.0.0 2.0.6
http >=0.11.0 <0.13.0 0.12.0+2
uuid ^1.0.0 1.0.3 2.0.1
Transitive dependencies
async 2.2.0
charcode 1.1.2
collection 1.14.11
convert 2.1.1
http_parser 3.1.3
meta 1.1.7
path 1.6.2
pedantic 1.7.0
source_span 1.5.5
string_scanner 1.0.4
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
test ^1.0.0