ronzeidman / ng2-ui-auth

an angular2 repository for authentication based on angular1's satellizer
MIT License
206 stars 64 forks source link

Getting error for twitter #146

Closed tuhin24 closed 6 years ago

tuhin24 commented 6 years ago

After getting ng2-auth-ui-example working for facebook, I tried it for twitter and getting following error. Any help is appreciated! Thanks

loginWithTwitter() { this.auth.authenticate('twitter') .subscribe({ error: (err: any) => alert(err.message), complete: () => this.router.navigateByUrl('main') }) }

<button type="button" class="btn btn-default" (click)="loginWithTwitter()">Login with Twitter

POST /auth/twitter - - ms - - [0] (node:28176) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property client_id of 'undefined' or 'null'. [0] at /Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/src/auth.ts:203:50 [0] at Generator.next () [0] at /Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/src/auth.ts:7:71 [0] at new Promise () [0] at awaiter (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/src/auth.ts:3:12) [0] at twitter (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/src/auth.ts:214:12) [0] at Layer.handle [as handle_request] (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/layer.js:95:5) [0] at next (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/route.js:137:13) [0] at Route.dispatch (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/route.js:112:3) [0] at Layer.handle [as handle_request] (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/layer.js:95:5) [0] at /Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:281:22 [0] at Function.process_params (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:335:12) [0] at next (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:275:10) [0] at middleware (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express-jwt/lib/index.js:78:16) [0] at Layer.handle [as handle_request] (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/layer.js:95:5) [0] at trim_prefix (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:317:13) [0] at /Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:284:7 [0] at Function.process_params (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:335:12) [0] at next (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:275:10) [0] at Function.handle (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:174:3) [0] at router (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:47:12) [0] at Layer.handle [as handle_request] (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/layer.js:95:5) [0] (node:28176) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3) [0] POST /auth/twitter - - ms - - [0] (node:28176) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property client_id of 'undefined' or 'null'. [0] at /Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/src/auth.ts:203:50 [0] at Generator.next () [0] at /Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/src/auth.ts:7:71 [0] at new Promise () [0] at awaiter (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/src/auth.ts:3:12) [0] at twitter (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/src/auth.ts:214:12) [0] at Layer.handle [as handle_request] (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/layer.js:95:5) [0] at next (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/route.js:137:13) [0] at Route.dispatch (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/route.js:112:3) [0] at Layer.handle [as handle_request] (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/layer.js:95:5) [0] at /Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:281:22 [0] at Function.process_params (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:335:12) [0] at next (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:275:10) [0] at middleware (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express-jwt/lib/index.js:78:16) [0] at Layer.handle [as handle_request] (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/layer.js:95:5) [0] at trim_prefix (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:317:13) [0] at /Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:284:7 [0] at Function.process_params (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:335:12) [0] at next (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:275:10) [0] at Function.handle (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:174:3) [0] at router (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/index.js:47:12) [0] at Layer.handle [as handle_request] (/Users/mohammadchowdhury/Downloads/SocialChamp/ngx-admin-master/server/node_modules/express/lib/router/layer.js:95:5) [0] (node:28176) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)

ronzeidman commented 6 years ago

Twitter flow is a bit different since it uses oauth 1.0a and not oauth 2. the server side implementation is a bit different, what did you receive as a body on your endpoint?

tuhin24 commented 6 years ago

Thanks Ron. I got it working after making some code changes. Facebook and Twitter are done. Now onto Linkedin.