Access token can be generated only as part of OAuth phase on app install or later as the merchant should review/accept/reject the request scope sent. Not sure I follow your case, would you provide more details on what you are trying to achieve?
You can't do that on the fly. Access token generation is an interactive process the merchant should give a consent for. How do you register for webhook updates? Are you doing that through admin?
The token generated at installation is permanent. It is invalidated only when the merchant uninstalls the app. AFAIK there is no way to programmatically generate a token on the fly, let's see what the community has to say.
We have an requirement to get the shopId inside a webhook receiving code.
Like whenever an order is created in the store i need to pass the shopId to some API. So we tried to do a graphql query (Admin API) to get shopId.But
But i am not able to get accesstoken in the context object. So query is not getting executed and returns error. Is there any way for getting accessToken inside web hook triggering code.
@mkarthique shop id is available in the request header - X-Shopify-Shop-Domain