json_web_token 0.1.3

  • README.md
  • Installing
  • Versions
  • 41


Json Web Token

Using OAuth 2.0 for Server to Server Applications


openssl pkcs12 -in privatekey.p12 -nocerts -passin pass:notasecret -nodes -out rsa_private_key.pem

String iss = "[your_id]@developer.gserviceaccount.com";
String scopes = "https://www.googleapis.com/auth/devstorage.read_only";
String rsa_private_key_file = "rsa_private_key.pem";

test('test 1' , (){
      JWT jwt = new JWT(iss, scopes);
      var pemkey = new File(rsa_private_key_file).readAsStringSync();
      rsa_pkcs.RSAPKCSParser parser = new rsa_pkcs.RSAPKCSParser();
      rsa_pkcs.RSAPrivateKey pk = parser.parsePEM(pemkey).private;
      var privk = new RSAPrivateKey(pk.modulus, pk.privateExponent, pk.prime1, pk.prime2);
      return jwt.generateAuthUsingKey(privk).then((_){
    test('test 2' , (){
      JWTStore.getCurrent().registerKey(iss, rsa_private_key_file);
     return  JWTStore.getCurrent().generateJWT(iss, scopes).then((JWT jwt){

once a token is generated it can be used with google api ...

import "package:google_analytics_v3_api/analytics_v3_api_console.dart";

Analytics analyticsClient = new Analytics(new oauth2.SimpleOAuth2Console(project, "", jwt.accessToken));
analyticsClient.makeAuthRequests = true;

Use this package as a library

1. Depend on it

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

  json_web_token: "^0.1.3"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:

      import 'package:json_web_token/json_web_token.dart';
Version Uploaded Documentation Archive
0.1.3 Apr 12, 2014 Go to the documentation of json_web_token 0.1.3 Download json_web_token 0.1.3 archive
0.1.1 Mar 28, 2014 Go to the documentation of json_web_token 0.1.1 Download json_web_token 0.1.1 archive
0.1.0 Mar 15, 2014 Go to the documentation of json_web_token 0.1.0 Download json_web_token 0.1.0 archive


We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
38 / 100
Code health derived from static analysis. [more]
74 / 100
Reflects how tidy and up-to-date the package is. [more]
0 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, other

Primary library: package:json_web_token/json_web_token.dart with components: io.


  • Maintain CHANGELOG.md.

    Changelog entries help clients to follow the progress in your code.

  • Package is too old.

    The package was released more than two years ago.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 error 13 hints.

    Strong-mode analysis of lib/src/JWT.dart failed with the following error:

    line: 153 col: 16
    The return type 'List' isn't a 'FutureOr<List<int>>', as defined by anonymous closure.

    Run dartfmt to format lib/json_web_token.dart.

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use json_web_token.dart.


Package Constraint Resolved Available
Direct dependencies
cipher >=0.7.0 <0.8.0 0.7.1
crypto >=0.9.0 <0.10.0 0.9.2+1 2.0.5
rsa_pkcs >=0.1.1 <0.2.0 0.1.1 0.1.2
Transitive dependencies
asn1lib 0.3.5 0.5.0
bignum 0.0.7 0.1.0
charcode 1.1.1
convert 1.1.1 2.0.1
fixnum 0.9.1+2 0.10.7
typed_data 1.1.5
Dev dependencies
unittest any