jprimes has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I would like to achieve the following:

An HTTP client implemented in Perl should redirect the user to an OAuth 2.0 authentication server. The user should authenticate exclusively through a web browser (e.g. Lynx) launched by the Perl script, since the HTTP client must not know the user's credentials.

Once the user has been successfully authenticated by the OAuth 2.0 authentication server through the browser, the HTTP response contains a redirect URI (typically in the Location header).

Question: is there a way to come back from the Lynx process to the Perl script, capturing the HTTP response received by Lynx in a Perl variable?

Please note that using a third-party user-agent is a requirement (so nothing for LWP).

Thank you in advance.

  • Comment on OAuth 2.0 - Starting Lynx from within a Perl script

Replies are listed 'Best First'.
Re: OAuth 2.0 - Starting Lynx from within a Perl script
by Corion (Patriarch) on Oct 01, 2015 at 10:15 UTC

    Net::Google::Drive::Simple does something similar to your task. I believe it achieves what you want by launching its own web server with a page, where the user then kicks of the OAuth2 dance. Maybe you can reuse the logic from that module?

      Thank you, actually I cannot.

      Regards,

Re: OAuth 2.0 - Starting Lynx from within a Perl script
by Anonymous Monk on Oct 01, 2015 at 17:36 UTC
    Do not overlook what you will find by searching for OAuth at http://search.cpan.org. Looks to be 346 modules, at this writing ...

      Thanks for the tip,

      but actually my question is more related to starting a process (the user's default browser, or Lynx) from a script, and capture the HTTP response after the user has been authenticated and eventually is being redirected (HTTP 302).

      Regards,