angular2-social-login icon indicating copy to clipboard operation
angular2-social-login copied to clipboard

Unable to integrate with angular universal

Open pravashupreti opened this issue 7 years ago • 2 comments

^ 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)

pravashupreti avatar Sep 07 '17 01:09 pravashupreti

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.

kpsrinivas avatar Sep 07 '17 04:09 kpsrinivas

@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.

imraqes avatar Oct 03 '17 13:10 imraqes