How can I get Google OAuth in catalyst app?

I am trying to use Google OAuth to authenticate with a Catalyst application . I've tried using CatalystX :: OAuth2 and Catalyst :: Authentication :: Credential :: OAuth , but I seem to be stuck with the setup.

I want it to work on Google and then go to Facebook

Is there any good advice? I'm killed to death, but there doesn't seem to be much.

+3


source to share


2 answers


I realize this question is almost 2 years old, but just in case it helps someone else, here is some information from weeks of testing and debugging. I also posted a test oauth2 client project using CatalystX :: OAuth2 at https://github.com/simonamor/oauth2-client - it works with google, although I haven't done everything with the token, but for example fetching information about the user profile and the "protected" page is broken. This may be enough to point you in the right direction.

The problem with CatalystX :: OAuth2 seemed to be that it didn't send the realm value and I can't find a way to send it and the Google API requires it. Not all vendors have this requirement, so it works well. By making a small change to my local copy of CatalystX :: OAuth2, I was able to get it to authenticate with Google. The changes (minor) are in a fork of this module, also in my github account.

Visit Google Developers Console and create OAuth2 credentials. You will need them below.

To my oauth2client.yml (from the github project mentioned above) I added the following:



Plugin::Authentication:
    default:
        credential:
            grant_uri: [provided by google, ends]/o/oauth2/v2/auth
            token_uri: [provided by google, ends]/oauth2/v4/token
            client_id: [issued by google]
            client_secret: [issued by google]
            scope: [provided by google, ends]/auth/userinfo.profile

      

I don't have a reputation high enough to post more than two links, so sorry for missing the portions of the URLs above! This was the only real configuration I needed to tweak. After changing my credentials settings, I also used it successfully with dropbox.com.

I am still working on the OAuth2 server side and this is the default configuration in the project, so you need to add an extra section for google.

+2


source


if you provided some information like where you are stuck and why, I could help.



There is an example configuration in cpan. If you are not using a config file, you can also add it to your Catalyst application, although I would recommend using a config file, just paste it into the example with the data you need specifically.

0


source







All Articles