d
Topic
Posts:
10
12 months ago

Code $_GET Params This post is outdated

I have a request.
But the answer is:

400 - Oauth error invalid_request / Oauth error invalid_request: The authorization code was not found or was already used

I didnt found, how can I generate $ _GET ['code'] I think when I create $_GET['code'], it will run straight. I think problem is $_GET['code']

My code is this:

$ client_id = 'xx';
$ client_secret = 'xxx';

$url = "https://" . $shop . "/admin/oauth/access_token";

$ post_data = array ('client_id' => $ client_id, 'client_secret' => $ client_secret, 'code' => $ _GET ['code']);

$ post_json = json_encode ($ post_data);

$ curl = curl_init ();

curl_setopt_array ($ curl, array (
     CURLOPT_URL => $ url,
     CURLOPT_RETURNTRANSFER => true,
     CURLOPT_TIMEOUT => 30,
     CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
     CURLOPT_CUSTOMREQUEST => "POST",
     CURLOPT_POSTFIELDS => $ post_json,
     CURLOPT_HTTPHEADER => array (
         "cache-control: no-cache",
         "content-type: application / json"
     )
));

Thank you.

i
Replies
Felix Member looga.io
Posts:
98
12 months ago
g
1
upvotes

As I understand it's:

1. Call "oauth/authorize?client_id=API_KEY&redirect_uri=REDIRECT_URL&scope=SCOPES

2. The redirect url should then get the $_GET['code']

3. Call "oauth/access_token" as in your code.

Looga.io