简体   繁体   中英

Integrating Passport with my Angular App: How to start authentication flow from client-side?

I am new to AngularJS and NodeJS.

I am using passport-facebook and passport-twitter for a project. Everything is set up properly on the server; getting the access token needed to make API calls.

But I do not know how to integrate it with my AngularJS app.

FBGraph is being used to make API calls, while passport-facebook was supposed to help me get the access token; but I cannot obviously use

$http.get(constant.BASEURL + "login/twitter");

which is the route that starts the authentication flow. It is working fine when the route is written directly into the address bar.

QUESTION: How can I start the authentication flow (pop up/redirect to permission page of Facebook/Twitter) from my Angular app?

As a temporary solution, I used Satellizer from client to get the access token, but it does not support Pinterest and Tumblr it seems.

Solution: Had to use $window.location.href = url to start the authentication flow rather than $http.get(url) ; the callbackUrl returned control to my application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM