Problems with OAuth on node.js

前端 未结 3 1541
别跟我提以往
别跟我提以往 2021-01-30 14:33

I am trying to get OAuth to work on node.js. I found this in the documentation of node-oauth:

var OAuth= require(\'oauth\').OAuth;
var oa = new OAuth(requestUrl,         


        
3条回答
  •  清酒与你
    2021-01-30 15:29

    The access token is issued to your application after walking the user through the "OAuth dance" (as its affectionately known). This means obtaining a request token and redirecting the user to the provider (Twitter, in this case) for authorization. If the user grants authorization, Twitter redirects the user back to your application with a code that can be exchanged for an access token.

    node-oauth can be used to manage this process, but a higher-level library will make it much easier. Passport (which I'm the author of), is one such library. In this case, check out the guide to Twitter authentication, which simplifies the OAuth dance down to a few lines of code.

    After that, you can save the access token in your database, and use it to access protected resources in the usual manner using node-oauth.

提交回复
热议问题