Angular JS - Connecting to Woocommerce OAuth v1

I am trying (unsuccessfully) to authenticate myself for a holiday service.

I tried this library to create all the parameters listed here , and I create the query this way:

$scope.oauth = new OAuth({
    consumer: {
        public: 'ck_d34c32d9c7f6fc1ddb6e85879fc4de89',
        secret: 'cs_1867e5e54ce054dde7cf463ad78ee6f9'
    },
    signature_method: 'HMAC-SHA1'
});

var request_data = {
        url: 'http://belfiore.link-me.it/wc-api/v1/orders',
        method: 'GET',
    }
    $scope.data = $scope.oauth.authorize(request_data);

    $scope.url = rawurlencode(request_data.url) + "&" + 
                "oauth_consumer_key"+"%3D"+rawurlencode($scope.data.oauth_consumer_key)+
                "%26"+"oauth_nonce"+"%3D"+rawurlencode($scope.data.oauth_nonce)+
                "%26"+"oauth_signature_method"+"%3D"+rawurlencode($scope.data.oauth_signature_method)+
                "%26"+"oauth_timestamp"+"%3D"+rawurlencode($scope.data.oauth_timestamp)+
                "%26"+"oauth_signature"+"%3D"+rawurlencode($scope.data.oauth_signature);

    var call = $http.get($scope.url);
    call.success(function(res) {
        console.log(res);
    });
    call.error(function(res) {
        console.log(res);
    });

but I keep getting the answer:

"Cannot GET /http%3A%2F%2Fbelfiore.link-me.it%2Fwc-api%2Fv1%2Forders&oauth_consumer_key%3Dck_d34c32d9c7f6fc1ddb6e85879fc4de89%26oauth_nonce%3DwkeLtFTh6WAuxDQGqnpzxAWYOQiHnHSr%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D10%26oauth_signature%3DjFhPbKHnvMEvYf20w1vN3TAV5Ds%3D"

Any help? I googled to find some tutorial or angular ready library fot OAuth1, but I did not find anything ...

early

+4
source share
2 answers

I am the author of oauth-1.0a lib

I have not tried angularjs yet, but just quickly looked at the following code:

$http({
    url: request_data.url,
    method: request_data.method,
    params: $scope.oauth.authorize(request_data)
});
0
source

rawurlencode - php-, javascript encodeURIComponent .

0

Source: https://habr.com/ru/post/1536820/


All Articles