paulvanbladel / aurelia-auth-sample

Sample for aurelia-auth
40 stars 20 forks source link

Crash using Google Sign In #5

Closed adriatic closed 9 years ago

adriatic commented 9 years ago

This could be a false alarm, as I did not provide " my own" versions of data in client/src/authConfig,js file (the development variant) under the assumption that I do not need to do it in order to get myself authenticated via Google Sign In.

Using the same assumption, I also created a copy of server/config/config.production.js and named it config.development.js (without changing its content)

I run the gulp watch from the client folder (assuming that Gulp will start the server side) and got the "normal" Navigation Skeleton app running. Then I clicked on Login button followed by SIgn in With Google.

The "cmd console" shows

C:\work\Aurelia-Guides\apps\aurelia-auth-sample\server\auth\google.js:58
          user.picture = profile.picture.replace('sz=50', 'sz=200');
                                        ^
TypeError: Cannot read property 'replace' of undefined
    at Query.<anonymous> (C:\work\Aurelia-Guides\apps\aurelia-auth-sample\server\auth\google.js:58:41)
    at C:\work\Aurelia-Guides\apps\aurelia-auth-sample\server\node_modules\mongoose\node_modules\kareem\index.js:177:19
    at C:\work\Aurelia-Guides\apps\aurelia-auth-sample\server\node_modules\mongoose\node_modules\kareem\index.js:109:16
    at process._tickCallback (node.js:355:11)
Error: read ECONNRESET
    at exports._errnoException (util.js:746:11)
    at TCP.onread (net.js:559:26)
[11:44:49] [nodemon] app crashed - waiting for file changes before starting...

and chrome console shows:

INFO [aurelia] Aurelia Started
aurelia-logging-console.js:38 DEBUG [templating] importing resources for http://localhost:4000/dist/app.html ["http://localhost:4000/dist/nav-bar", "bootstrap/css/bootstrap.css"]
aurelia-logging-console.js:38 DEBUG [templating] importing resources for http://localhost:4000/dist/nav-bar.html []
aurelia-logging-console.js:38 DEBUG [templating] importing resources for http://localhost:4000/dist/welcome.html []
welcome.js:31 dispose subscription
aurelia-logging-console.js:38 DEBUG [templating] importing resources for http://localhost:4000/dist/login.html []
aurelia-http-client.js:275 POST http://localhost:4000/auth/google 500 (Internal Server Error)processRequest @ aurelia-http-client.js:275f @ shim.min.js:1415(anonymous function) @ shim.min.js:1423b.exports @ shim.min.js:453b.(anonymous function) @ shim.min.js:1625f @ shim.min.js:1596q @ shim.min.js:1600
oAuth2.js:105 error :undefined
shim.min.js:1444 Unhandled promise rejection HttpResponseMessage {requestMessage: HttpRequestMessage, statusCode: 500, response: "Error: read ECONNRESET<br> &nbsp; &nbsp;at exports…)<br> &nbsp; &nbsp;at TCP.onread (net.js:559:26)↵", isSuccess: false, statusText: "Internal Server Error"…}(anonymous function) @ shim.min.js:1444b.exports @ shim.min.js:453b.(anonymous function) @ shim.min.js:1625f @ shim.min.js:1596q @ shim.min.js:1600
shim.min.js:1444 Unhandled promise rejection HttpResponseMessage {requestMessage: HttpRequestMessage, statusCode: 500, response: "Error: read ECONNRESET<br> &nbsp; &nbsp;at exports…)<br> &nbsp; &nbsp;at TCP.onread (net.js:559:26)↵", isSuccess: false, statusText: "Internal Server Error"…}(anonymous function) @ shim.min.js:1444b.exports @ shim.min.js:453b.(anonymous function) @ shim.min.js:1625f @ shim.min.js:1596q @ shim.min.js:1600
shim.min.js:1444 Unhandled promise rejection HttpResponseMessage {requestMessage: HttpRequestMessage, statusCode: 500, response: "Error: read ECONNRESET<br> &nbsp; &nbsp;at exports…)<br> &nbsp; &nbsp;at TCP.onread (net.js:559:26)↵", isSuccess: false, statusText: "Internal Server Error"…}(anonymous function) @ shim.min.js:1444b.exports @ shim.min.js:453b.(anonymous function) @ shim.min.js:1625f @ shim.min.js:1596q @ shim.min.js:1600

I did not try to debug anything yet, as I am aiming at a different target at the moment - writing the about plugins for Aurelia-Guides, so I wanted to peek into some details of a plugin (how does the client of a plugin (aurelia-auth-sample) gain access of plugin)

adriatic commented 9 years ago

An obvious question related to the aurelia-auth-sample: what are the clientId strings in auth.config.js file:

        configForDevelopment = {
                providers: {
                    google: {
                        clientId: '239531826023-xxxxx.apps.googleusercontent.com'
                    },

                    linkedin: {
                        clientId: 'yyyyyyy'
                    },
                    facebook: {
                        clientId: 'zzzzzzzzzzz'
                    }
                }
            };

I am just presuming that these are the "secret keys" for your own credentials for each of these authentication providers - and then it makes no sense to keep them in that config file??

I must be missing something here :-)

paulvanbladel commented 9 years ago

I took my own sources from github (git clone in a temp folder) and provided server side the correct config.development.js, did both client ander server side npm install, and everything seems to work correctly. This is also confirmed by others. So... difficult for me to see what differs in your setup. It' seems it goes wrong already server side from the log you provide.

Regarding the "secret keys". Well... they are not secret, the cryptographic material in the client project (basically clientIDs) is as public as a public key in an RSA key pair, everyone may know these, because you need them to identify the app (as registered by the authentication provider, e.g. google). What is very private, is the material server side (the client_secret), that's why I didn't check in the file config.development.js server side in github, I don't want that my google account gets compromised. Obviously, you need to replace both client and server side, the Ids en secrets with the ones you register at google/facebook/....

adriatic commented 9 years ago

I will debug it nevertheless as the problem (as I understood it) has to do with trying to access my picture (which is a part of my google id) and that is something that might be my account specific, so you could not reproduce it

paulvanbladel commented 9 years ago

No, I can't reproduce and quite some people are already using the lib.... But, obviously feel free to re-open the issue if debugging on your side leads to something useful. I would try to put some breakpoints server side.

adriatic commented 9 years ago

That is exactly what I want to do - and I use Webstorm for that :-).

paulvanbladel commented 9 years ago

could you isolate the problem ?