Skip to content
SOP v1.1 Authentication for Perl5
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/WebService/SOP/Auth
t
xt
.gitignore
.proverc
.travis.yml
Build.PL
Changes
LICENSE
META.json
README.md
cpanfile
minil.toml

README.md

Build Status

NAME

WebService::SOP::Auth::V1_1 - SOP version 1.1 authentication module

SYNOPSIS

use WebService::SOP::Auth::V1_1;

To create an instance:

my $auth = WebService::SOP::Auth::V1_1->new({
    app_id => '1',
    app_secret => 'hogehoge',
});

When making a GET request to API:

my $req = $auth->create_request(
    GET => 'https://<API_HOST>/path/to/endpoint' => {
        hoge => 'hoge',
        fuga => 'fuga',
    },
);

my $res = LWP::UserAgent->new->request($req);

When making a POST request with JSON data to API:

my $req = $auth->create_request(
    POST_JSON => 'http://<API_HOST>/path/to/endpoint' => {
        hoge => 'hoge',
        fuga => 'fuga',
    },
);

my $res = LWP::UserAgent->new->request($req);

When embedding JavaScript URL in page:

<script src="<: $req.uri.as_string :>"></script>

DESCRIPTION

WebService::SOP::Auth::V1_1 is an authentication module for SOP version 1.1 by Research Panel Asia, Inc.

METHODS

new( \%options ) returns WebService::SOP::Auth::V1_1

Creates a new instance.

Possible options:

  • app_id

    (Required) Your app_id.

  • app_secret

    (Required) Your app_secret.

  • time

    (Optional) POSIX time.

app_id() returns Int

Returns app_id configured to instance.

app_secret() returns Str

Returns app_secret configured to instance.

time returns Int

Returns time configured to instance.

create_request( Str $type, Any $uri, Hash $params ) returns HTTP::Request

Returns a new HTTP::Request object for API request while adding app_id to parameters by default.

$type can be one of followings:

  • GET

    For HTTP GET request to SOP endpoint with signature in query string as parameter sig.

  • POST

    For HTTP POST request to SOP endpoint with signature in query string as parameter sig of request content type application/x-www-form-urlencoded.

  • POST_JSON

    For HTTP POST request to SOP endpoint with signature as request header X-Sop-Sig of request content type application/json.

  • PUT

    For HTTP PUT request to SOP endpoint with signature in query string as parameter sig of request content type application/x-www-form-urlencoded.

  • PUT_JSON

    For HTTP PUT request to SOP endpoint with signature as request header X-Sop-Sig of request content type application/json.

  • DELETE

    For HTTP DELETE request to SOP endpoint with signature in query string as parameter sig.

verify_signature( Str $sig, Hash $params ) return Int

Verifies and returns if request signature is valid.

SEE ALSO

WebService::SOP::Auth::V1_1::Request::DELETE, WebService::SOP::Auth::V1_1::Request::GET, WebService::SOP::Auth::V1_1::Request::POST, WebService::SOP::Auth::V1_1::Request::POST_JSON, WebService::SOP::Auth::V1_1::Request::PUT, WebService::SOP::Auth::V1_1::Request::PUT_JSON, WebService::SOP::Auth::V1_1::Util

LICENSE

Copyright (C) dataSpring, Inc. Copyright (C) Research Panel Asia, Inc.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

yowcow <yoko.oyama [ at ] d8aspring.com>

You can’t perform that action at this time.