Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
provide easy way to use oauth for mt plugins
Perl
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
plugins
README.pod

README.pod

NAME

MT-OAuth-Framework

DESCRIPTION

A Movable Type plugin helps other plugins using OAuth. This plugin can manage consumer credentials, do and manage handshake with service provider for each user, access to protected resources and it's fallback.

SYNOPSIS

For MT User

At first, MT Administrator, maybe who had installed a plugin which using this framework, should do register your MT instance as New Application to the OAuth Service Provider.

  • Go to System > Settings > OAuth Servers
  • click "regist this MT to SERVICEPROVIDER"
  • Enter information about your MT Install as application
  • save them, then look for consumer key and consumer secret in the service provider site
  • Copy consumer key and consumer secret and paste them to MT setting screen
  • save

OK, now your MT install can handshake with the service provider. after that, let's see the plugin's instruction.

For Plugin writter

 ## Add service provider information to config.yaml of your plugin.

 oauth_service_providers:
     example_provider:
         label: Example Provider
         regist_url: http://dev.example.com/apps/new/
         manage_url: http://dev.example.com/apps/
         request_token_url: https://api.example.com/oauth/request_token
         access_token_url: https://api.example.com/oauth/access_token
         authorize_url: https://api.example.com/oauth/authorize

 ## And you perl code..

 use MT::OAuth;

 sub post {
     my ($app) = shift;
     my (%forward) = @_;
     ## get parameters at retry...
     my $text = $forward{post}{text} || $app->param('text');
     my $author = $app->user or die;
     my $client = MT::OAuth->client('example_provider');
     return $server->access(
         author_id => $author->id,
               end_point => 'https://example.com/statuses/update.xml',
         post => {
             status => $text,
         },
         retry => 1,  ## request to MT to go back to this method after handshaking.
         callback => sub {
             ## when accessing to the resource is finished, this will be called.
             return $app->return_to_dashboard;
         },
     );
 }

 ## this is all.
 ## if the author hasn't yet authorized, MT will automatically do handshake, and 
 ## after handshaked, back to the method again.

Run with MT4.x

Some of perl modules bundled with MT4.x is too old to run this plugin. here is steps to run OAuthFramework plugin with MT4.x.

1) remove these files and directories from your ( MT4_HOME )/extlib directory. * HTTP/ * LWP/ * LWP.pm

2) ( if you still got errors about LWP::*** or HTTP::***, ) install LWP to you system via CPAN or your system's package manager.

Something went wrong with that request. Please try again.