Generate access token during webhook event

ariesbe
Shopify Partner
3 0 0

Is there any way that I can generate new access token without the generated "code", during I received a webhook event. Let say I want to update the order based on certain business rule that I have as part of the processing of the event data. Thanks!

0 Likes
Visely-Team
Shopify Partner
1835 210 434

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?

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
ariesbe
Shopify Partner
3 0 0
Thanks for reply.

I was looking into doing API call during webhook event to update something. So I was looking into generating access token on the fly. Is that possible or the token genrated during installation is the only option? Thanks.
0 Likes
Visely-Team
Shopify Partner
1835 210 434

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?

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
ariesbe
Shopify Partner
3 0 0
Thanks, During merchant installation registration is done programmatically using admin rest api. If I do not have the generated code that was given during installation, would access token generation on the fly would still be possible? Right now I treat the token generated during installation as permanent token, not sure if thats the correct way hence I am looking for other ways to access the API dynamically. I also looking if these would be possible for cloud functions as well. I hope I explain it well. Again, thanks.
0 Likes
Visely-Team
Shopify Partner
1835 210 434

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.

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
mkarthique
New Member
12 0 0

Hi,

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.

 

 

0 Likes
Visely-Team
Shopify Partner
1835 210 434

@mkarthique shop id is available in the request header - X-Shopify-Shop-Domain

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes