Mojo-JWT-Google

 view release on metacpan or  search on metacpan

lib/Mojo/JWT/Google.pm  view on Meta::CPAN

    $result->{exp} = $self->issue_at + $self->expires_in;
  }
  return $result;
}

sub from_json {
  my ($self, $value) = @_;
  croak 'You did not pass a filename to from_json' if not defined $value;
  croak 'Cannot find file passed to from_json' if not -f $value;
  my $json = decode_json( path($value)->slurp );
  croak 'private key was not found in file passed to from_json' unless $json->{private_key};
  croak 'from_json only works with service accounts' if $json->{type} ne 'service_account';
  $self->algorithm('RS256');
  $self->secret($json->{private_key});
  $self->client_email($json->{client_email});
  return 1
}

sub as_form_data {
  my ($self) = @_;
  return {
    grant_type => 'urn:ietf:params:oauth:grant-type:jwt-bearer',
    assertion => $self->encode
  }

t/load1.json  view on Meta::CPAN

{
  "private_key_id": "8",
  "private_key": "-----BEGIN PRIVATE KEY-----\nMIIC\nk8KLWw6r/ERRBg\u003d\u003d\n-----END PRIVATE KEY-----\n",
  "client_email": "9dvse@developer.gserviceaccount.com",
  "client_id": "ihkkmv89dvse.apps.googleusercontent.com",
  "type": "service_account"
}

t/load3.json  view on Meta::CPAN

{
  "private_key_id": "8",
  "client_email": "9dvse@developer.gserviceaccount.com",
  "client_id": "ihkkmv89dvse.apps.googleusercontent.com",
  "type": "service_account"
}

t/load4.json  view on Meta::CPAN

{
  "private_key_id": "8",
  "private_key": "-----BEGIN PRIVATE KEY-----\nMIIC\nk8KLWw6r/ERRBg\u003d\u003d\n-----END PRIVATE KEY-----\n",
  "client_email": "9dvse@developer.gserviceaccount.com",
  "client_id": "ihkkmv89dvse.apps.googleusercontent.com",
  "type": "not_a_service_account"
}



( run in 0.248 second using v1.01-cache-2.11-cpan-4d50c553e7e )