heresy / angular2-social-login

Simple client side social authentication for Angular2 application.
30 stars 38 forks source link

Unable to integrate with angular universal #23

Open pravashupreti opened 7 years ago

pravashupreti commented 7 years ago

^ ReferenceError: document is not defined at Object.google (C:\xampp\htdocs\SOFTWEBDEVELOPERS\classmonk\client\node_modules\angular2-social-login\dist\bundles\angular2-social-login.min.js:1:3652) at C:\xampp\htdocs\SOFTWEBDEVELOPERS\classmonk\client\node_modules\angular2-social-login\dist\bundles\angular2-social-login.min.js:1:4502 at Array.forEach () at Function.e.loadProvidersScripts (C:\xampp\htdocs\SOFTWEBDEVELOPERS\classmonk\client\node_modules\angular2-social-login\dist\bundles\angular2-social-login.min.js:1:4478) at Object. (C:\xampp\htdocs\SOFTWEBDEVELOPERS\classmonk\client\src\app\app.module.ts:228:27) at Module._compile (module.js:573:30) at Module.m._compile (C:\xampp\htdocs\SOFTWEBDEVELOPERS\classmonk\client\node_modules\ts-node\src\index.ts:392:23) at Module._extensions..js (module.js:584:10) at Object.require.extensions.(anonymous function) [as .ts] (C:\xampp\htdocs\SOFTWEBDEVELOPERS\classmonk\client\node_modules\ts-node\src\index.ts:395:12) at Module.load (module.js:507:32)

kpsrinivas commented 7 years ago

At this point, it won't work with angular universal. There are some dom dependencies in the code. We need to figure out a way to execute logout. Let me look at it.

imraqes commented 7 years ago

@kpsrinivas @pravash-upreti

Yes you can use it with Angular Universal also

add this stuff in your app.component.ts

import { Angular2SocialLoginModule } from "angular2-social-login";

let providers = {
    "google": {
      "clientId": "GOOGLE_CLIENT_ID"
    },
    "linkedin": {
      "clientId": "LINKEDIN_CLIENT_ID"
    },
    "facebook": {
      "clientId": "FACEBOOK_CLIENT_ID",
      "apiVersion": "v2.4"
    }
  };

And Inside constructor you can do this

if(this.isBrowser){
            Angular2SocialLoginModule.loadProvidersScripts(providers);
}

isBrowser is basically to check if your running in server or browser.