How to know when there is an issue inside npm_modules?

Hi @shiran-kohai , @yisrael-wix ,

I saw that you were involved in npm_modules topics, so I tagged you. Hope that’s right.

I used the available “oauth” npm module, but seems at the first real call the callbacks are not called at all:

oa.getOAuthRequestToken( (error, oAuthToken, oAuthTokenSecret, results) => {
console.log(Request Token: ${oAuthToken}, secret: ${oAuthTokenSecret}, error: ${error}, results: ${results});
}

The npm import seems to work and the construction of the OAuth object as well:

var OAuth = require (‘oauth’);

let oa = new OAuth.OAuth(
https://connectapi.garmin.com/oauth-service/oauth/request_token’,
https://connectapi.garmin.com/oauth-service/oauth/access_token’,
consumerKey,
consumerSecret,
‘1.0’,
callbackURL,
‘HMAC-SHA1’
);

Is there a way I can understand whether there is an error? Are others using this “oauth” npm module successfully (OAuth 1.0 version)?

Thanks much!
Zsolt

I haven’t used this one myself, although do you have the full code for it as you haven’t listed the oauth.get( code that should follow it.
https://www.npmjs.com/package/oauth

The code isn’t much more. The flow starts from the Wix frontend, which calls a backend function that initializes the OAuth npm and object, then calls the first oa.getOAuthRequestToken(callback) function which does not return at all.

I assume the oa.get() cannot be utilized in Wix as this would download some resource (as in Twitter example) but does not redirect the browser to the Garmin Connect https://connect.garmin.com/oauthConfirm URL with the oauth_token (request token) to prompt the user with the Garmin Connect page where he can authorize my website to consume user data from Garmin. In order to do that, I assumed I need to use wix-location.to(), but even with this solution I ran into another blocker, I cannot add the “Authorization” header in the wix-location.to() call.

Am I missing something?

Can someone please confirm that once you are loading an npm_module the dependencies are also loaded somehow?

Taking a look at the source code of the ‘oauth’ npm i can see there are number of dependencies:
var crypto= require(‘crypto’),
sha1= require(‘./sha1’),
http= require(‘http’),
https= require(‘https’),
URL= require(‘url’),
querystring= require(‘querystring’),
OAuthUtils= require(‘./_utils’);

Thanks much!
Zsolt