authorize: function() { let authUrl; if ( config( 'oauth_client_id' ) ) { const port = process.env.PORT || config( 'port' ); const oauthSettings = { response_type: 'token', client_id: config( 'oauth_client_id' ), client_secret: 'n/a', url: { redirect: `http://calypso.localhost:${ port }/api/oauth/token`, }, }; const wpoauth = WPOAuth( oauthSettings ); authUrl = wpoauth.urlToConnect( { scope: 'global', blog_id: 0 } ); } ReactDom.render( React.createElement( ConnectComponent, { authUrl: authUrl, } ), document.getElementById( 'primary' ) ); },
app.set('view engine', 'jade'); /** * WP app settings */ var wp_app = { "client_id": "38002", "client_secret": "jNzfpqPY8tUPKK2oQQRvCvWpzAowIY3O2TadIHRkmx47Kbe0pfo7Jb4FKNbKjKh8", "url": { "redirect": "http://jsconfar.test:3000/connect" } }; // Open athentication instance var oauth = OAuth(wp_app); // Main route app.get('/', function (req, res) { var url = oauth.urlToConnect(); res.render('index', { url: url }); }); // Get code to WP.com app.get('/connect', function (req, res) { var code = req.query.code; // set oauth code ... oauth.code(code); // ... and negotiate by access token