diff --git a/assets/php/etsyData/authorizeEtsy.php b/assets/php/etsyData/authorizeEtsy.php new file mode 100644 index 0000000..950e98e --- /dev/null +++ b/assets/php/etsyData/authorizeEtsy.php @@ -0,0 +1,25 @@ + 'code', + 'client_id' => $clientId, + 'redirect_uri' => $redirectUri, + 'scope' => $scope, + 'state' => $state +]); + +header("Location: $url"); +exit; +?> diff --git a/assets/php/etsyData/callbackEtsy.php b/assets/php/etsyData/callbackEtsy.php new file mode 100644 index 0000000..ac52c12 --- /dev/null +++ b/assets/php/etsyData/callbackEtsy.php @@ -0,0 +1,33 @@ + 'authorization_code', + 'client_id' => $clientId, + 'client_secret' => $clientSecret, + 'code' => $code, + 'redirect_uri' => $redirectUri +]; + +$ch = curl_init("https://api.etsy.com/v3/public/oauth/token"); +curl_setopt($ch, CURLOPT_POST, true); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); +$response = curl_exec($ch); +$tokens = json_decode($response, true); + +file_put diff --git a/assets/php/etsyData/refreshTokenEtsy.php b/assets/php/etsyData/refreshTokenEtsy.php new file mode 100644 index 0000000..95e2695 --- /dev/null +++ b/assets/php/etsyData/refreshTokenEtsy.php @@ -0,0 +1,27 @@ + 'refresh_token', + 'client_id' => $_ENV['ETSY_KEYSTRING'], + 'client_secret' => $_ENV['ETSY_SECRET'], + 'refresh_token' => $refreshToken + ]; + + $ch = curl_init("https://api.etsy.com/v3/public/oauth/token"); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); + $response = curl_exec($ch); + $newTokens = json_decode($response, true); + + file_put_contents('etsyTokens.json', json_encode($newTokens)); + echo "Token refreshed successfully."; +} +?>