Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get access token and shop info #109

Open
krutipatel-8794 opened this issue Oct 3, 2022 · 3 comments
Open

Can't get access token and shop info #109

krutipatel-8794 opened this issue Oct 3, 2022 · 3 comments

Comments

@krutipatel-8794
Copy link

I am trying to get an access token using exchange_temporary_token method but I don't get any error or any successful response.
I am implementing this node API in the AWS Lambda function.

var Shopify = new shopifyAPI({
				 shop: 'SHOP_NAME', 
				 shopify_api_key: 'API_KEY', // Your API key
				 shopify_shared_secret: 'API_SHARED_SECRET'// Your Shared Secret
			 });

Shopify.exchange_temporary_token(event['queryStringParameters'], function (err, data){
	if (err)
	{
		console.log(err);
	}
	else {
		console.log(data);
	}

	console.log('Access token is..', data['access_token']);
});

I am using the correct shopify_api_key and shopify_shared_secret, but I can't see any error OR any data result OR access_token.
I can successfully call Shopify.is_valid_signature method and it is returning 'True' value.
Any suggestions for this on how I can get the details?

My 2nd question is:
I have also tried to call the below code, and the same issue (No errors, no data, no headers). I am calling this by setting my temporary token in the config

var Shopify = new shopifyAPI({
				 shop: 'SHOP_NAME', 
				 shopify_api_key: 'API_KEY', // Your API key
				 shopify_shared_secret: 'API_SHARED_SECRET', // Your Shared Secret
                                 access_token: event['queryStringParameters'].code
			 });

Shopify.get('admin/api/2022-07/shop.json', "", function(err, data, headers){
                console.log(err); 
                console.log(data); // Data contains product json information
                console.log(headers); // Headers returned from request
            });

image

As per the docs the 2nd parameter query_params is optional so I haven't passed any.
Could you please suggest how I can get the shop details?

@nodeit
Copy link
Collaborator

nodeit commented Oct 3, 2022

It's hard to tell without any sort of stack trace or error message. Are you able to reproduce the error locally? Testing in AWS lambda can be tricky.

@krutipatel-8794
Copy link
Author

No, I haven't tested this locally and only tried with Lambda. But I can try testing locally and will let you know.

@krutipatel-8794
Copy link
Author

@nodeit I have tested this locally and I can get an access token but when I try the same code in lambda then it does not return an error or data. I feel like it doesn't execute the method itself. Do you know if anyone had the same issue before and has a resolution?

await Shopify.exchange_temporary_token(queryParams, async function(err, data){
                console.log("err is....", err);
                console.log("data is....", data);
                console.log("access token is....", data['access_token']);
                accessToken = data['access_token'];
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants