OAuth redirection is not working on ios safari.

Highlighted
New Member
1 0 0

Hi everyone. I am creating mobile app to use shopify api.

For using shopify api, use shopify oauth first. it works well. After login with my account, redirect from safari from to app and can get authorization code and so can get access code and can use this access code to use shopify apis.

        https://{shop}.myshopify.com/admin/oauth/authorize?client_id={api_key}&scope={scopes}&redirect_uri={redirect_uri}&state={nonce}&grant_options[]={access_mode}

I used above url and can get like as following url with authorization code:

        https://{redirect_url}/auth?code=285415edf29f1166fa57f66a76f7f720&hmac=ce7772255c0fcb55a47c8bee18094079c856da6de0dc5ae4e5ed2eecbac1dc6c&shop=tarragonapp.myshopify.com&timestamp=1588999362

 

But when token is expired, and so need to receive authorization code, and so oauth again. Then my app open safari but there is a saved cookie in safari and so there is no login form and generate authorization code. but doesn't redirect to the app. So app can't get authorization code.

Thanks in your advance.

 

 

0 Likes
Highlighted
Shopify Staff (Retired)
Shopify Staff (Retired)
624 102 125

Hi @waterflower1259 ,

 

During the initial OAuth flow when the merchant is installing your app and you are redirecting the user to the following URL https://{shop}.myshopify.com/admin/oauth/authorize, if you set the field of `grant_options[]` as blank instead of per-user then your access mode will be set to Offline instead of Online.

 

With Offline access mode your access token will only expire if the merchant uninstalls your app. This way you do not have to worry about the token expiring after the session ends and starting the OAuth session over again and again. 

 

I would also recommend looking into the libraries like the koa-shopify-auth Node.js package and shopify_app ruby gem to help handle the OAuth process for your app: https://www.npmjs.com/package/@shopify/koa-shopify-auth and https://github.com/shopify/shopify_app

 

Hassain | Developer Support Specialist @ Shopify
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution 

0 Likes