How to add new scope to an existing public app

Solved
sbdev
Shopify Partner
32 0 3

Hello All,

I want to add a few new scopes to my existing public app. When I have added my scope in my existing app then I got this error in Shopify embedded app. 

Message: example-store.com refused to connect.

There are a couple of solutions and posts that are present who put light on this topic but still I am a little bit confused about this.

My current authentication URL is : https://{$shop}/admin/oauth/authorize?client_id={$apiKey}&scope={$scope}&redirect_uri={$redirectUri}

I have seen I am supposed to add one or two-parameters in my Shopify authentication URL and Shopify will automatically handle this reauthentication process.
(1) state=nonce
(2)grant_options[]={access_mode}

My current authentication URL is : https://{$shop}/admin/oauth/authorize?client_id={$apiKey}&scope={$scope}&redirect_uri={$redirectUri}

I have put nonce as a random number and grant_options[]={access_mode}. I have passed same as it is like a string "grant_options[]={access_mode}" also wrote blank for once. Is access_mode refer anything here? what am I supposed to pass here?


Below given are the URLs which I have tried to reach the reauthentication.
(1) https://{$shop}/admin/oauth/authorize?client_id={$apiKey}&scope={$scope}&redirect_uri={$redirectUri}&state={512549293}
(2) https://{$shop}/admin/oauth/authorize?client_id={$apiKey}&scope={$scope}&redirect_uri={$redirectUri}&state={1132363175}&grant_options[]={access_mode}
(3) https://{$shop}/admin/oauth/authorize?client_id={$apiKey}&scope={$scope}&redirect_uri={$redirectUri}&state={9132363178}&grant_options[]={}

All of the times I have got the same error example-store.com refused to connect. 

I surely tried to understand these two parameters state and grant_options but not very much clear about these.

I hope someone helps me with this as I am stuck into this. 

Thank you for hearing me.


0 Likes
SBD_
Shopify Staff
Shopify Staff
1044 141 185

Hey @sbdev 

Any chance you can provide a screenshot of the error screen (with URL)?

sbdev
Shopify Partner
32 0 3

Hello @SBD_ ,

 

Thank you for your reply.

Kindly check the error screenshot:   https://prnt.sc/ug0cpn

This error comes when the user redirect to the URL inside the ifamre and the URL is :   "https://{$shop}/admin/oauth/authorize?client_id={$apiKey}&scope={$scope}&redirect_uri={$redirectUri}";

We have observed that if we redirect the user when inside the iframe we get this error but if we copy the URL and open in the new tab then the app user redirect to Shopify update app page/wizard

Any idea what is the issue or how we can tackle this?

Thanks in advance.

0 Likes
SBD_
Shopify Staff
Shopify Staff
1044 141 185

This is an accepted solution.

Thanks @sbdev 

The iframe might need to be escaped, can you try something like this?

window.top.location = <authorize url>


Or if you're using shopify_app, there's a full_page_directect_to helper.

sbdev
Shopify Partner
32 0 3

Hello @SBD_,

Thank you for suggesting to us the javascript way of doing this.

window.top.location = <authorize url>

 

Surely, We can use the above-given code to achieve what we want to. Also, we are not using any library/pre-cooked code such as shopify_app. We are developing an app on our own and from scratch. I would surely like to ask that for custom code/app is there any other solution or existing helper/anything besides this window.top.location who can help us to accomplish this?. I would surely like to know some options if they exist. 

Thank you so much.


0 Likes