Monks,

I have spent the last 2 days scouring the internet for information on how to authenticate a perl app using oauth2. There are a half-dozen modules that claim to assist with this process, and not a single one has documentation or examples or any hint on how to construct the request successfully.

I decided to work with LWP::Authen::OAuth2 and came up with the following code (This is for attempting to authenticate with Yahoo).

The number one issue I have is the redirect_uri. It seems like the oauth2 spec always assumes that any developer has access to their own website to host a redirect page on? This must be super-obvious, because every tutorial site just hand-waves over this parameter with "put your redirect uri here" without even attempting to suggest what one might look like, especially if you're running a standalone application. Some sites mentioned that you can redirect to localhost... again, without any sort of suggestion as to how you might do that.

So... question 1. How to I form a redirect URI for a locally executed application in a windows environment?

I'm sure I have more questions and errors in my code, but I won't be able to find those until I can fill in some reasonable value for the redirect_uri.

use LWP::Authen::Oauth2; use Storable; #to save and restore token for future use use Term::Prompt; use strict; use warnings; my $oauth2 = LWP::Authen::OAuth2->new( client_id => '*****', client_secret => '*****', redirect_uri => 'I don't even know', scope => 'fspt-w', response_type => 'id_token' ); my $url = $oauth2->authorization_url('https://api.login.yahoo.com/oaut +h2/request_auth'); my $code = prompt('x', 'Paste the code obtained at the above URL here: + ', '', ''); # Exchange the code for an access token: my $token = $oauth2->get_access_token($code) or die; # If we get to here, it worked! Report success: print "\nToken obtained successfully!\n"; print "Here are the token contents (just FYI):\n\n"; print $token->to_string, "\n";

In reply to Oauth2 help needed by superwombat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.