Access token of an app with only functions

How do I retrieve the access token for the ADMIN API in a custom app without a frontend, using only functions?

I imagine you’re running into something similar here, have a read and see if its helpful/relevant.

Hi @GabrielTurnes,

Moving forward with custom apps created via the Dev Dashboard, you can utilize the new Client Credentials Grant workflow to receive the access tokens for an app that doesn’t have any frontend UI capable to implement the other authorization workflows that require user redirects like Authorization Code Grants

Essentially you will need to make a POST https://{shop}.myshopify.com/admin/oauth/access_token HTTP request, passing the Client ID and Client Secret in the request body, which can be retrieved from the app’s settings in the Dev Dashboard, as described here:

1 Like

Hi @GabrielTurnes,

I just wanted to share an update here to clarify some access requirements for Client Credential Grants, to ensure there is no confusion with it’s use.

It’s important to note that this authorization workflow is only available for Custom Apps created from the same account as the store it’s being installed on.

This means the following:

  • Apps created from the Dev Dashboard while logged into a Partner Account can only use this on that Partner’s Development Stores.
  • Apps created from the Dev Dashboard while logged into a Merchant Account, can use this on that merchant’s stores.
  • Apps created from Partner Account can’t use this on Merchant stores the app is installed on (even if the Partner Account has collaborator access)

This means that Partner created apps, installed on Merchant stores will still need to use either the token exchange or authorization code grant workflows for authentication.

Otherwise, you can get the Merchant to create and install the app themselves from their Dev Dashboard, then provide you with the app credentials for use with the client credential grant workflow.