Laravel-ShopifyAPI icon indicating copy to clipboard operation
Laravel-ShopifyAPI copied to clipboard

Client error: `POST https://testing-4pi.myshopify.com/admin/oauth/access_token` resulted in a `400 Bad Request` response: {"error":"invalid_request"}

Open 1quintana opened this issue 6 years ago • 0 comments

I see this issue was posted and fixed in a new pull request and I already have the fix in my code, but I am still facing this problem.

I added the url to web.php

Route::get('/oauth/authorize', 'ShopifyController@getResponse');
Route::get('/shopify', 'ShopifyController@getPermission');

Here is my controller

<?php

namespace App\Http\Controllers;

use Shopify;
use Illuminate\Http\Request;

class ShopifyController extends Controller
{
    protected $shop = "testing-4pi.myshopify.com";
    protected $foo;
    protected $scopes = ['read_products','read_themes'];
    

    public function getPermission()
    {
        $this->foo = Shopify::make($this->shop, $this->scopes);
        return $this->foo->redirect();
    }
    
    public function getResponse(Request $request)
    {
        $this->getPermission();
        
        // Get user data, you can store it in the data base
        $user = $this->foo->auth()->getUser();
        
        //GET request to products.json
        return $this->foo->auth()->get('products', ['fields'=>'id,images,title']);
    }
}

1quintana avatar May 07 '19 17:05 1quintana