dwyl / hapi-auth-google

:lollipop: Let people authenticate with your application/website using their Google Account (OAuth2)
GNU General Public License v2.0
41 stars 6 forks source link

Sorry, something went wrong, please try again. #29

Open keerthivasan-r opened 8 years ago

keerthivasan-r commented 8 years ago

Hi, I have integrated the plugin with our hapi server. Thanks for the plugin. When i click on Signin with Google buttton, it takes to the google page, when the user enters credentials and allow access to the application. Everything happens fine. But, the profile data is not being sent by google. Is there any settings that i miss?

if (profile) {
        debugger;
        // extract the relevant data from Profile to store in JWT object
        var session = {
            firstname: profile.name.givenName,
            image: profile.image.url,
            id: profile.id,
            exp: Math.floor(new Date().getTime() / 1000) + 7 * 24 * 60 * 60,
            agent: req.headers['user-agent']
        };
        // create a JWT to set as the cookie:
        var token = JWT.sign(session, process.env.JWT_SECRET);
        // store the Profile and Oauth tokens in the Redis DB using G+ id as key
        // Detailed Example...? https://github.com/dwyl/hapi-auth-google/issues/2
        console.log(profile);
        // reply to client with a view
        return reply("Hello " + profile.name.givenName + " You Logged in Using Goolge!")
            .state('token', token); // see: http://hapijs.com/tutorials/cookies
    }
    else {
        return reply("Sorry, something went wrong, please try again.");
    }

It always enter the else loop in the above code. I really appreciate your help

nelsonic commented 8 years ago

@keerthivasan-r apologies for taking so long to get back to you. did you figure it out? Once you have the Oauth2 Token are you requesting the person's profile info?