Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1quintana opened this issue May 7, 2019 · 0 comments

Comments

@1quintana
Copy link

1quintana commented May 7, 2019

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 1quintana reopened this May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant