amzn / amazon-advertising-api-php-sdk

⛔️ DEPRECATED - Amazon Advertising API PHP Client Library
Apache License 2.0
93 stars 66 forks source link

{"code":"401","details":"Authentication failed","requestId":"K144VZX9J0CCDG4229C5"} #10

Closed cmakanhasoft closed 6 years ago

cmakanhasoft commented 6 years ago

i have used this amazon-advertising-api-php-sdk api but i got every time one error like Authentication failed. so please suggest me how to solved that. here is my code $code = $_REQUEST['code']; $postfields = array( 'grant_type'=>'authorization_code', 'code'=>$code, 'client_id'=>client_id, 'client_secret'=>client_secret ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.amazon.com/auth/o2/token'); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/x-www-form-urlencoded;charset=UTF-8']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postfields)); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // On dev server only! $result = curl_exec($ch); $newResult= json_decode($result);

    $config = array(
        "clientId" => client_id,
        "clientSecret" => client_secret,
        "region" => "na",
        //"accessToken" => $newResult->access_token,
        "refreshToken" => $newResult->refresh_token,
        "sandbox" => TRUE);

   $client = new Client($config);
   $d=$client->registerProfile(array("countryCode" => "US"));
        print_r($d);
dbrent-amazon commented 6 years ago

Hello,

Please open a Jira Service Desk ticket for issues integrating with the Advertising API. If you do not have a Service Desk account and have onboarded with the API, please respond to the onboarding email with a technical email address so one can be created for you.

Brent

cmakanhasoft commented 6 years ago

Thanks for reply I have a question. A compulsory developer account must be created to use AIDS API?

On Thu, Jun 21, 2018 at 4:28 PM, Brent notifications@github.com wrote:

Hello,

Please open a Jira Service Desk ticket for issues integrating with the Advertising API. If you do not have a Service Desk account and have onboarded with the API, please respond to the onboarding email with a technical email address so one can be created for you.

Brent

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/amzn/amazon-advertising-api-php-sdk/issues/10#issuecomment-399164410, or mute the thread https://github.com/notifications/unsubscribe-auth/AX2F_RhrRvAg8tfrW6x2alUuhonNjz4wks5t-8mngaJpZM4UxeDg .

--

Thanks & Regards Seema Patel

ritz07 commented 4 years ago

Hi Guys,

Is there any way get refresh token without follow this step https://www.amazon.com/ap/oa?client_id=YOUR_LWA_CLIENT_ID&scope=cpc_advertising:campaign_management&response_type=code&redirect_uri=YOUR_RETURN_URL or is there any way to get authorization code by CURL

Thanks

Prasand14 commented 3 years ago

Hi @ritz07,

Where you able to do it. Because i'm stuck in the same point. Thanks in advance.

cmakanhasoft commented 3 years ago

May be you have no permission for advertising api So please check in seller center account. There are available advertise menu. Plz check you have permission of that menu or not.

On Wed, 31 Mar, 2021, 11:08 am Prasand Kumar, @.***> wrote:

Hi @ritz07 https://github.com/ritz07,

Where you able to do it. Because i'm stuck in the same point. Thanks in advance.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/amzn/amazon-advertising-api-php-sdk/issues/10#issuecomment-810778639, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF6YL7IOVUX226ICBESYPHLTGKYOPANCNFSM4FGF4DQA .

ritz07 commented 3 years ago

Hi @ritz07,

Where you able to do it. Because i'm stuck in the same point. Thanks in advance.

Hi @Prasand14

First time you have to manually run this url than you will get refresh token and auth token copy this code and save it.. after that you can refresh token without this url..