Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shopify: Problems Getting OAuth Access Token

I've retrieved the authorization code in Step 1 of OAuth without a problem, but for the life of me I can't complete a post to get the access token. I always get the same error:

content: "{"error":"invalid_request","error_description":"Could not find Shopify API appli... (length: 103)"

Here's what my code looks like...Meteor.http.post is a standard post request. I've tried all sorts of combinations without any luck. I'm developing on localhost:

var url = 'https://' + shopName + '/admin/oauth/access_token';    
var data = { client_id: apiKey, client_secret: secret, code: code };

Meteor.http.post(url, data,
    function(error, result) {
        debugger;
    });

Meteor.post is a standard server-side post request documented here. I've tried params (like the Node Wrapper), an array (like PHP) and a combination of other things. I have no idea.

Is it because I'm developing on localhost and server calls require https now? Is my post data structure wrong?

Any other ideas what I'm doing wrong?

like image 387
Brandon Avatar asked Jan 16 '13 20:01

Brandon


1 Answers

I know you said you tried params but placing the params in as data like that wouldn't work. Try this..

var url = 'https://' + shopName + '/admin/oauth/access_token';    
var data = { client_id: apiKey, client_secret: secret, code: code };

Meteor.http.post(url, {params:data},
    function(error, result) {
        debugger;
});
like image 114
Tarang Avatar answered Oct 01 '22 22:10

Tarang