At the end of the OAuth flow I redirect to the main apppage with the apiKey and the shopOrigin as query parameters. I can initialize via the polaris using <AppProvider>, but how can i "save" the apiKey and the shopOrigin for cases where the user goes to some other admin page and returns to the app page via the app link in the admin module?
Should I access it though the initialized Shopify App Bridge instance via Reacts context, set a cookie or the like?
I see the Shopify App Bridge documentation suggests a HttpOnly cookie, but thats for setting the data for the server - I just want to know best practise for setting the parameters when the page is accessed after the OAuth flow.
I guess I could check whether the query parameters are set, and if not ask the server for the shopOrigin in the session, but is it the best way to do it?
When you mention the apiKey are you referring to the actual API key or the access token you receive from the oauth flow? If you're referring to the access token, I would suggest storing this in a database along with the shopOrigin that access token belongs to. Then when the merchant leaves your app and returns, a `shop` query parameter will be provided. You can use that to pull the access token from your database and make any authenticated requests.
I hope that helps, but let me know if I'm missing anything.
Thank you for your answer.
I already use the method you describe for storing and retrieving the access token from the server. It's been a while since I wrote the post, but I think I wondered whether there was a way to save the information on the client side, such that a server call was not necessary.
Furthermore, when the first server call has been made, and the access token is retrieved via the shop query parameter, I guess the access token should only be set once in Shopify Polaris during the session, but how?
|an hour ago|
|3 hours ago|
|5 hours ago|
|6 hours ago|
|8 hours ago|