Sign-in with twitter using angular

2019-02-15 07:02发布

I am trying to implement singin functioanlity using angular2 , Read from official documentation also from here , But didn't get how the flow is going on. my questions are

  1. what are the parameters for accessing first step i.e outh_token ?
  2. is there any working example or best articles which teach the flow ?
  3. I have read number of questions on SO but none of them work for me.

any suggestion will be appreciated.

PS: as of now i am Hitting Post request on this URL

let url = 'http://twitter.com/oauth/request_token?oauth_callback=http%3A%2F%2Fgoogle.com%2Ftwittercallback&oauth_consumer_key=my_consumer_key&oauth_nonce=ea9ec8429b68d6b77cd5600adbbb0456&oauth_signature=F1Li3tvehgcraF8DMJ7OyxO4w9Y&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1318467427&oauth_version=1.0';

But throwing error status code 307.

also i had tried using ng2-twitter package but not working.

2条回答
一纸荒年 Trace。
2楼-- · 2019-02-15 07:27

I suggest looking at great real world example here https://github.com/gothinkster/angular-realworld-example-app which uses oauth. I also implemented my sample angular app with full working client/server code to login to Facebook, Linkedin and Google https://github.com/anjmao/adify using ExpressJs and PassportJs.

查看更多
倾城 Initia
3楼-- · 2019-02-15 07:35

If you use AngularFire2, then you can get it done by just one line and that is

logintwitter(){
    this.afAuth.auth.signInWithPopup(new firebase.auth.TwitterAuthProvider());
  }
查看更多
登录 后发表回答