semifor / Net-Twitter

A Perl interface to the Twitter APIs
83 stars 37 forks source link

added OAuth to Identica #1

Closed barbie closed 13 years ago

barbie commented 14 years ago

Hi Marc,

Tried the addition of the oauth_urls as suggested and with this very minor change to Net/Identica.pm all seems to work fine. I may not have covered all edge cases, but at least the trials I've just done all seems to access my Identica account okay.

Cheers, Barbie.

semifor commented 14 years ago

That patch, unfortunately, has the effect of requiring OAuth for Identica. When the OAuth trait is included, consumer_key and consumer_secret are required. So, apps using Basic Auth for Identica would fail.

Net::Identica should be deprecated. It exists simply to provide backwards compatibility. It wold be better to use Net::Twitter directly. That way, OAuth can be requested, as needed, by the application code.

Where can I find documentation for the Identica OAuth end points?

If we simlpy include the OAuth URLs in Net::Twitter::Role::API's around BUILDARGS modifier, then calling code can be:

my $identica = Net::Twitter::New->(
    traits => [qw/OAuth API::REST/],
    identica => 1,
    consumer_key => $key,
    consumer_secret => $secret,
);

Net::Identica sets trait Legacy. It pulls in trait WrapError, which causes errors to return undef, and provides method get_error for obtaining error information through package globals. I think that's a poor error strategy, and is one reason Net::Twitter 3.x was created. I'd like to see users be able to move away from that strategy and use Net::Twitter's ability to throw exceptions, instead.

For backwards compatibility, to support code that relies on the old error strategy, just include trait WrapError (or Legacy if some of the other legacy features are needed).

What do you think?

barbie commented 14 years ago

Drat I didn't go back and test the Basic Authentication. However, I think the method you describe is probably the better way forward. I'll have a play with Maisha and see how it goes.

The URLs I used were:

    oauth_urls => {
        request_token_url  => "https://identi.ca/api/oauth/request_token",
        authentication_url => "https://identi.ca/api/oauth/authenticate",
        authorization_url  => "https://identi.ca/api/oauth/authorize",
        access_token_url   => "https://identi.ca/api/oauth/access_token",
        xauth_url          => "https://identi.ca/api/oauth/access_token"
    },

I had to include the xauth_url as it complained without it :(

Will let you now how it works.

Cheers, Barbie.

barbie commented 14 years ago

BTW the Identi.ca link I started from is http://status.net/wiki/TwitterCompatibleAPI

When you login to Identi.ca you register apps at http://identi.ca/settings/oauthapps

HTH, Barbie.

semifor commented 14 years ago

How's this: http://github.com/semifor/Net-Twitter/commit/d3afada365dc501c293bfcb6471c6323cb49b9fb

barbie commented 14 years ago

Excellent, that seems to do the trick. Thanks for all the help Marc, much appreciated.

Cheers, Barbie.