Shopify shop tokens now expiring after 24 hours?

Solved

Shopify shop tokens now expiring after 24 hours?

Chad_Johnson
Shopify Partner
33 1 18

I developed an app in the past. When the app is installed, Shopify delivers a token to our app which can be used to make calls to Shopify's API on behalf of the store. This token never expired (or the expiration was relatively far in the future).

I'm developing a new app now, and I'm noticing that access tokens are expiring in 24 hours. These tokens begin with 'shpat_'.

My app will need to make requests on behalf of the shop to Shopify's API daily. It's no good if access tokens expire for shops after 24 hours.

So what gives? Did Shopify make some change? Or is this happening because my app is in development mode? What's going on?

Accepted Solution (1)

Chad_Johnson
Shopify Partner
33 1 18

This is an accepted solution.

Solved.

I am using the @shopify/koa-shopify-auth package, and turns out accessMode is by default set to "online", and per the docs, online access token lifetimes match the lifetimes of the user's web session.

The solution was to set accessMode to "offline" via the shopifyAuth middleware function.

View solution in original post

Replies 3 (3)

Chad_Johnson
Shopify Partner
33 1 18

This is an accepted solution.

Solved.

I am using the @shopify/koa-shopify-auth package, and turns out accessMode is by default set to "online", and per the docs, online access token lifetimes match the lifetimes of the user's web session.

The solution was to set accessMode to "offline" via the shopifyAuth middleware function.

Leo_Huynh
Tourist
7 1 6

Thanks, !

 

 

app.use(
	shopifyAuth({
		accessMode: 'offline',
		async afterAuth(ctx) {
			const { shop, accessToken } = ctx.state.shopify
			// handle after auth....
		},
	}),
)

 

 

Leo Huynh | Shopify Software Engineer @ Insights Studio
Email: leo@insights.is
Personal site: https://leohuynh.dev
adityazappush
Shopify Partner
2 0 0

quality answer 🙂