Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get error with google login #259

Closed
ccwinder opened this issue Nov 24, 2016 · 14 comments
Closed

Get error with google login #259

ccwinder opened this issue Nov 24, 2016 · 14 comments

Comments

@ccwinder
Copy link

Hi, sir

I try to setup a local server for hackmd. But when I try to setup google login, I got error message as below.

Can you give me some suggestion or steps to debug?

Error
    at /home/ccwinder/hackmd/node_modules/passport-google-oauth20/lib/strategy.js:95:21
    at passBackControl (/home/ccwinder/hackmd/node_modules/oauth/lib/oauth2.js:123:9)
    at IncomingMessage.<anonymous> (/home/ccwinder/hackmd/node_modules/oauth/lib/oauth2.js:143:7)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
2016-11-24T23:07:23.153Z - info: ::ffff:10.0.2.2 - - [24/Nov/2016:23:07:23 +0000] "GET /auth/google/callback?code=4/sUOc2hv1qX3SZt1qEVg4eFun2LxHQBulqR9EyTOy1Ps HTTP/1.1" 500 22 "http://localhost:3000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"
@jackycute
Copy link
Member

Hi @ccwinder
Could paste your config.json here?

@ccwinder
Copy link
Author

Hi, jacky

My config.json

 14     "production": {
 15         "domain": "localhost",
 16         "urladdport": true,
 17         "db": {
 18             "username": "root",
 19             "password": "xxxxxxxx",
 20             "database": "hackmd",
 21             "host": "127.0.0.1",
 22             "port": "3306",
 23             "dialect": "mysql"
 24         },

Below is my OAuth 2.0 Client ID information

 46         "google": {
 47             "clientID": "xxxxxxxxxx-8jloaghp4jh9cb9pdglnf3mrn1gmlvud.apps.googleusercontent.com",
 48             "clientSecret": "xxxxxxxxxxxxxxxxxx"
 49         },

Should I configure public/js/config.js?

@jackycute
Copy link
Member

Did you add http://localhost to your Google API console credentials allow reference url?

@ccwinder
Copy link
Author

My OAuth 2.0 client ID setting
In 已授權的 JavaScript 來源,I fill in http://localhost:3000
In 已授權的重新導向 URI,I fill in http://localhost:3000/auth/google/callback

Is it correct?

@jackycute
Copy link
Member

That settings are good.
Maybe remove "domain": "localhost", in your config.json and try again after restart server?

@ccwinder
Copy link
Author

I remove "domain": "localhost" in my config.json. But the result is still fail.
Thanks for you help!
Is there any debug mode I can open to get more information?

@jackycute
Copy link
Member

jackycute commented Nov 25, 2016

Did you restart your server?
You could set "debug": true and also running your server in development instead of production might showing more debug message.

@ccwinder
Copy link
Author

Yes, I have restarted my server.
But I don't see any much more new message, the message is as below.
Should I enable any Google API?

2016-11-25T03:52:52.437Z - info: ::ffff:10.0.2.2 - - [25/Nov/2016:03:52:52 +0000] "GET /auth/google HTTP/1.1" 302 0 "http://localhost:3000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"

2016-11-25T03:53:09.592Z - info: Executing (default): SELECT `sid`, `expires`, `data`, `createdAt`, `updatedAt` FROM `Sessions` AS `Session` WHERE `Session`.`sid` = 'HMBg9l4z2d9f5GQVdtrOUz7ffUPfegLp';
Error
    at Strategy.OAuth2Strategy._createOAuthError (/home/ccwinder/hackmd/node_modules/passport-oauth2/lib/strategy.js:370:17)
    at /home/ccwinder/hackmd/node_modules/passport-oauth2/lib/strategy.js:166:45
    at /home/ccwinder/hackmd/node_modules/oauth/lib/oauth2.js:177:18
    at ClientRequest.<anonymous> (/home/ccwinder/hackmd/node_modules/oauth/lib/oauth2.js:148:5)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at TLSSocket.socketErrorListener (_http_client.js:309:9)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at connectErrorNT (net.js:1025:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
2016-11-25T03:53:29.688Z - info: Executing (default): UPDATE `Sessions` SET `expires`='2016-12-09 03:53:29',`updatedAt`='2016-11-25 03:53:29' WHERE `sid` = 'HMBg9l4z2d9f5GQVdtrOUz7ffUPfegLp'
2016-11-25T03:53:29.700Z - info: ::ffff:10.0.2.2 - - [25/Nov/2016:03:53:29 +0000] "GET /auth/google/callback?code=4/Yvjsd0QyuTMVmUxUygaGujTzrNPZwM7YqUJxg19wMvA HTTP/1.1" 500 921 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"

@jackycute
Copy link
Member

Yes, you have to enable Google Plus API

@ccwinder
Copy link
Author

Hi, Jacky
After doing two steps as below, currently, I can log in by Google Account.

  1. Enable Google Plus API
  2. Change setting of 已授權的重新導向 URI. From http://localhost:3000/auth/google/callback to http://localhost/auth/google/callback

I am not sure if it is reasonable. I will try more experiments.
Thanks for your help! It is a great software.

@jackycute
Copy link
Member

You're welcome!
Reopen if you have further issues.

@Acesonnall
Copy link

Enabling and changing the setting fixed my issue too.

@ahornerr
Copy link

I've attached the debugger and I believe this is the error message from Google for this stack trace:

Access Not Configured. Google+ API has not been used in project ******** before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/plus/overview?project=******** then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

@kumaresan-perumal
Copy link

@jackycute After Enabling api. It worked for me. thanks man

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants