Invalid API key or access token

Invalid API key or access token

fahim-ng
Shopify Partner
2 0 0
public function configureTheme(Request $request)
{
$shop = Auth::user();

 

$themes = $shop->api()->rest('GET', '/admin/themes.json');
dd($themes);
$activeThemeId = "";
foreach($themes['body']->container['themes'] as $theme){
if($theme['role'] == "main"){
$activeThemeId = $theme['id'];
}
}
 
}
it returns 
"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)
Please can any one help ?
Replies 2 (2)

Liam
Shopify Staff
2873 312 821

Can you confirm that the API key and access tokens are both correct and active?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

fahim-ng
Shopify Partner
2 0 0

Yes, I set this in the environment file (SHOPIFY_API_KEY and SHOPIFY_API_SECRET) and utilise middleware (verify.shopify)

when route call.
I get the app user data from ($shop = Auth::user();) but  when get shopify api like $themes = $shop->api()->rest('GET', '/admin/themes.json');
it generates the Invalid API key or access token (unrecognized login or wrong password) error??

Thanks in Advance