How to implement Net :: OpenID :: Consumer to log in to Google and request a user’s email?

I was able to successfully use Net :: OpenID :: Consumer, but when I started asking for the user's email address, Google now prompts the user to allow the sharing of their email address. This happens every time, regardless of whether the user checks the Remember This Statement check box. How to get Google to request a user every time?

Our site Registration and login for OpenID login are the same, otherwise we could only request an email address from Google when a user registers.

I will try to publish a sufficiently appropriate code (this application is for dancers).

my $csr = Net::OpenID::Consumer->new( ua => LWP::UserAgent->new(), consumer_secret => $secret, ); my $claimed_identity = $csr->claimed_identity('https://www.google.com/accounts/o8/id'); $claimed_identity->set_extension_args( "http://openid.net/srv/ax/1.0", { 'mode' => 'fetch_request', 'type.email' => 'http://axschema.org/contact/email', 'required' => 'email', }); my $check_url = $claimed_identity->check_url( return_to => 'http://my.site.com/openid_landing', trust_root => 'http://my.site.com', delayed_return => 1, ); 

Yahoo does not seem to have this problem. I think this may be a problem for Google, but I'm betting on my code.

+4
source share
1 answer

The Google Developers Guide shows that your application URL must match the value of the openid.realm parameter in the OpenID request for a smooth login without an authorization page. Having said that, I think you should specify required_root to match trust_root , something like -

 my $csr = Net::OpenID::Consumer->new( ua => LWP::UserAgent->new(), consumer_secret => $secret, required_root => "http://my.site.com" ); 
+1
source

Source: https://habr.com/ru/post/1436454/


All Articles