Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect) magento rest api errorMage registry key “_singleton/admin/session” already existsInvalid auth/bad request. Magento rest apiMagento 2.2.2 REST API - I need to change the customer password using REST APIM2.1.x REST API - Invalid type for value array. Expected type: stringMagento2 REST API 400 bad request specific error codes401 Authorization Required Magento 2 REST APIMagento 2 Rest API using basic AuthIf we can access data by using simple http request ,then why to use rest or soap api or curl?Retreive product list Magento REST API errorInvalid signature error on rest-api retrieve productsMagento Api request foreach error

Constructing Group Divisible Designs - Algorithms?

Varistor? Purpose and principle

Reply 'no position' while the job posting is still there

Two-sided logarithm inequality

Journal losing indexing services

How do I repair my stair bannister?

Why do IPv6 unique local addresses have to have a /48 prefix?

Should I install hardwood flooring or cabinets first?

Did arcade monitors have same pixel aspect ratio as TV sets?

Can someone explain how this makes sense electrically?

What is the gram­mat­i­cal term for “‑ed” words like these?

Will adding a BY-SA image to a blog post make the entire post BY-SA?

Some numbers are more equivalent than others

Is it improper etiquette to ask your opponent what his/her rating is before the game?

Customize circled numbers

List of people who lose a child in תנ"ך

Greatest common substring

Is possible to search in vim history?

How will losing mobility of one hand affect my career as a programmer?

Why did the HMS Bounty go back to a time when whales are already rare?

Can a significant change in incentives void an employment contract?

Why did the EU agree to delay the Brexit deadline?

API Access HTML/Javascript

MAXDOP Settings for SQL Server 2014



Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect) magento rest api error


Mage registry key “_singleton/admin/session” already existsInvalid auth/bad request. Magento rest apiMagento 2.2.2 REST API - I need to change the customer password using REST APIM2.1.x REST API - Invalid type for value array. Expected type: stringMagento2 REST API 400 bad request specific error codes401 Authorization Required Magento 2 REST APIMagento 2 Rest API using basic AuthIf we can access data by using simple http request ,then why to use rest or soap api or curl?Retreive product list Magento REST API errorInvalid signature error on rest-api retrieve productsMagento Api request foreach error













3















Error message below




Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a
redirect)
"messages":"error":["code":401,"message":"oauth_problem=internal_error&message=Mage
registry key "_singleton/admin/session" already exists"]




This error showing when I try to get all products via Rest api in magento 1.9.3.4.



Below is the code



$callbackUrl = "magentohost/test.php";
$temporaryCredentialsRequestUrl = "magentohost/oauth/initiate?oauth_callback=" . urlencode($callbackUrl);
$customerAuthorizationUrl = 'magentohost/oauth/authorize';
$accessTokenRequestUrl = 'magentohost/oauth/token';
$apiUrl = 'magentohost/api/rest';
$consumerKey = 'xxxxxxxxxxxxxxxxxxxx';
$consumerSecret = 'xxxxxxxxxxxxxxxxxx';

session_start();
if (!isset($_GET['oauth_token']) && isset($_SESSION['state']) && $_SESSION['state'] == 1)
$_SESSION['state'] = 0;

try
$authType = ($_SESSION['state'] == 2) ? OAUTH_AUTH_TYPE_AUTHORIZATION : OAUTH_AUTH_TYPE_URI;
$oauthClient = new OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, $authType);
$oauthClient->enableDebug();

if (!isset($_GET['oauth_token']) && !$_SESSION['state'])
$requestToken = $oauthClient->getRequestToken($temporaryCredentialsRequestUrl);
$_SESSION['secret'] = $requestToken['oauth_token_secret'];
$_SESSION['state'] = 1;
header('Location: ' . $customerAuthorizationUrl . '?oauth_token=' . $requestToken['oauth_token']);
exit;
else if ($_SESSION['state'] == 1)
$oauthClient->setToken($_GET['oauth_token'], $_SESSION['secret']);
$accessToken = $oauthClient->getAccessToken($accessTokenRequestUrl);
$_SESSION['state'] = 2;
$_SESSION['token'] = $accessToken['oauth_token'];
$_SESSION['secret'] = $accessToken['oauth_token_secret'];
header('Location: ' . $callbackUrl);
exit;
else
$oauthClient->setToken($_SESSION['token'], $_SESSION['secret']);

$resourceUrl = "$apiUrl/products";
$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json', 'Accept' => 'application/json'));
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);

catch (OAuthException $e)
print_r($e->getMessage());
echo "<br/>";
print_r($e->lastResponse);



Please help me to resolved this issue. Thanks in advance.










share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • please give any solution

    – Ashok
    Sep 21 '17 at 9:47















3















Error message below




Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a
redirect)
"messages":"error":["code":401,"message":"oauth_problem=internal_error&message=Mage
registry key "_singleton/admin/session" already exists"]




This error showing when I try to get all products via Rest api in magento 1.9.3.4.



Below is the code



$callbackUrl = "magentohost/test.php";
$temporaryCredentialsRequestUrl = "magentohost/oauth/initiate?oauth_callback=" . urlencode($callbackUrl);
$customerAuthorizationUrl = 'magentohost/oauth/authorize';
$accessTokenRequestUrl = 'magentohost/oauth/token';
$apiUrl = 'magentohost/api/rest';
$consumerKey = 'xxxxxxxxxxxxxxxxxxxx';
$consumerSecret = 'xxxxxxxxxxxxxxxxxx';

session_start();
if (!isset($_GET['oauth_token']) && isset($_SESSION['state']) && $_SESSION['state'] == 1)
$_SESSION['state'] = 0;

try
$authType = ($_SESSION['state'] == 2) ? OAUTH_AUTH_TYPE_AUTHORIZATION : OAUTH_AUTH_TYPE_URI;
$oauthClient = new OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, $authType);
$oauthClient->enableDebug();

if (!isset($_GET['oauth_token']) && !$_SESSION['state'])
$requestToken = $oauthClient->getRequestToken($temporaryCredentialsRequestUrl);
$_SESSION['secret'] = $requestToken['oauth_token_secret'];
$_SESSION['state'] = 1;
header('Location: ' . $customerAuthorizationUrl . '?oauth_token=' . $requestToken['oauth_token']);
exit;
else if ($_SESSION['state'] == 1)
$oauthClient->setToken($_GET['oauth_token'], $_SESSION['secret']);
$accessToken = $oauthClient->getAccessToken($accessTokenRequestUrl);
$_SESSION['state'] = 2;
$_SESSION['token'] = $accessToken['oauth_token'];
$_SESSION['secret'] = $accessToken['oauth_token_secret'];
header('Location: ' . $callbackUrl);
exit;
else
$oauthClient->setToken($_SESSION['token'], $_SESSION['secret']);

$resourceUrl = "$apiUrl/products";
$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json', 'Accept' => 'application/json'));
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);

catch (OAuthException $e)
print_r($e->getMessage());
echo "<br/>";
print_r($e->lastResponse);



Please help me to resolved this issue. Thanks in advance.










share|improve this question
















bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • please give any solution

    – Ashok
    Sep 21 '17 at 9:47













3












3








3








Error message below




Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a
redirect)
"messages":"error":["code":401,"message":"oauth_problem=internal_error&message=Mage
registry key "_singleton/admin/session" already exists"]




This error showing when I try to get all products via Rest api in magento 1.9.3.4.



Below is the code



$callbackUrl = "magentohost/test.php";
$temporaryCredentialsRequestUrl = "magentohost/oauth/initiate?oauth_callback=" . urlencode($callbackUrl);
$customerAuthorizationUrl = 'magentohost/oauth/authorize';
$accessTokenRequestUrl = 'magentohost/oauth/token';
$apiUrl = 'magentohost/api/rest';
$consumerKey = 'xxxxxxxxxxxxxxxxxxxx';
$consumerSecret = 'xxxxxxxxxxxxxxxxxx';

session_start();
if (!isset($_GET['oauth_token']) && isset($_SESSION['state']) && $_SESSION['state'] == 1)
$_SESSION['state'] = 0;

try
$authType = ($_SESSION['state'] == 2) ? OAUTH_AUTH_TYPE_AUTHORIZATION : OAUTH_AUTH_TYPE_URI;
$oauthClient = new OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, $authType);
$oauthClient->enableDebug();

if (!isset($_GET['oauth_token']) && !$_SESSION['state'])
$requestToken = $oauthClient->getRequestToken($temporaryCredentialsRequestUrl);
$_SESSION['secret'] = $requestToken['oauth_token_secret'];
$_SESSION['state'] = 1;
header('Location: ' . $customerAuthorizationUrl . '?oauth_token=' . $requestToken['oauth_token']);
exit;
else if ($_SESSION['state'] == 1)
$oauthClient->setToken($_GET['oauth_token'], $_SESSION['secret']);
$accessToken = $oauthClient->getAccessToken($accessTokenRequestUrl);
$_SESSION['state'] = 2;
$_SESSION['token'] = $accessToken['oauth_token'];
$_SESSION['secret'] = $accessToken['oauth_token_secret'];
header('Location: ' . $callbackUrl);
exit;
else
$oauthClient->setToken($_SESSION['token'], $_SESSION['secret']);

$resourceUrl = "$apiUrl/products";
$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json', 'Accept' => 'application/json'));
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);

catch (OAuthException $e)
print_r($e->getMessage());
echo "<br/>";
print_r($e->lastResponse);



Please help me to resolved this issue. Thanks in advance.










share|improve this question
















Error message below




Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a
redirect)
"messages":"error":["code":401,"message":"oauth_problem=internal_error&message=Mage
registry key "_singleton/admin/session" already exists"]




This error showing when I try to get all products via Rest api in magento 1.9.3.4.



Below is the code



$callbackUrl = "magentohost/test.php";
$temporaryCredentialsRequestUrl = "magentohost/oauth/initiate?oauth_callback=" . urlencode($callbackUrl);
$customerAuthorizationUrl = 'magentohost/oauth/authorize';
$accessTokenRequestUrl = 'magentohost/oauth/token';
$apiUrl = 'magentohost/api/rest';
$consumerKey = 'xxxxxxxxxxxxxxxxxxxx';
$consumerSecret = 'xxxxxxxxxxxxxxxxxx';

session_start();
if (!isset($_GET['oauth_token']) && isset($_SESSION['state']) && $_SESSION['state'] == 1)
$_SESSION['state'] = 0;

try
$authType = ($_SESSION['state'] == 2) ? OAUTH_AUTH_TYPE_AUTHORIZATION : OAUTH_AUTH_TYPE_URI;
$oauthClient = new OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, $authType);
$oauthClient->enableDebug();

if (!isset($_GET['oauth_token']) && !$_SESSION['state'])
$requestToken = $oauthClient->getRequestToken($temporaryCredentialsRequestUrl);
$_SESSION['secret'] = $requestToken['oauth_token_secret'];
$_SESSION['state'] = 1;
header('Location: ' . $customerAuthorizationUrl . '?oauth_token=' . $requestToken['oauth_token']);
exit;
else if ($_SESSION['state'] == 1)
$oauthClient->setToken($_GET['oauth_token'], $_SESSION['secret']);
$accessToken = $oauthClient->getAccessToken($accessTokenRequestUrl);
$_SESSION['state'] = 2;
$_SESSION['token'] = $accessToken['oauth_token'];
$_SESSION['secret'] = $accessToken['oauth_token_secret'];
header('Location: ' . $callbackUrl);
exit;
else
$oauthClient->setToken($_SESSION['token'], $_SESSION['secret']);

$resourceUrl = "$apiUrl/products";
$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json', 'Accept' => 'application/json'));
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);

catch (OAuthException $e)
print_r($e->getMessage());
echo "<br/>";
print_r($e->lastResponse);



Please help me to resolved this issue. Thanks in advance.







magento-1.9 api rest-api






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 21 '17 at 9:46









Manoj Deswal

4,38791744




4,38791744










asked Sep 21 '17 at 9:42









AshokAshok

162




162





bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community yesterday


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • please give any solution

    – Ashok
    Sep 21 '17 at 9:47

















  • please give any solution

    – Ashok
    Sep 21 '17 at 9:47
















please give any solution

– Ashok
Sep 21 '17 at 9:47





please give any solution

– Ashok
Sep 21 '17 at 9:47










1 Answer
1






active

oldest

votes


















0














What role are you using to retrieve the products? Administrator, Customer or Guest? And are you running the test.php on the same host as the magento installation you are trying to reach? It seems so from your code. If so, has the host IP restriction in place? This can mean it will not allow calls from its own IP address...



In your error it says "_singleton/admin/session" already exists so at least have a look at Mage registry key "_singleton/admin/session" already exists



I don't have enough information but I think you may be trying to retrieve the products with the administrator role and your test.php is on the same host as your magento installation that you are questioning and you may have issues with IP restriction...






share|improve this answer






















    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "479"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f194097%2finvalid-auth-bad-request-got-a-401-expected-http-1-1-20x-or-a-redirect-magent%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    What role are you using to retrieve the products? Administrator, Customer or Guest? And are you running the test.php on the same host as the magento installation you are trying to reach? It seems so from your code. If so, has the host IP restriction in place? This can mean it will not allow calls from its own IP address...



    In your error it says "_singleton/admin/session" already exists so at least have a look at Mage registry key "_singleton/admin/session" already exists



    I don't have enough information but I think you may be trying to retrieve the products with the administrator role and your test.php is on the same host as your magento installation that you are questioning and you may have issues with IP restriction...






    share|improve this answer



























      0














      What role are you using to retrieve the products? Administrator, Customer or Guest? And are you running the test.php on the same host as the magento installation you are trying to reach? It seems so from your code. If so, has the host IP restriction in place? This can mean it will not allow calls from its own IP address...



      In your error it says "_singleton/admin/session" already exists so at least have a look at Mage registry key "_singleton/admin/session" already exists



      I don't have enough information but I think you may be trying to retrieve the products with the administrator role and your test.php is on the same host as your magento installation that you are questioning and you may have issues with IP restriction...






      share|improve this answer

























        0












        0








        0







        What role are you using to retrieve the products? Administrator, Customer or Guest? And are you running the test.php on the same host as the magento installation you are trying to reach? It seems so from your code. If so, has the host IP restriction in place? This can mean it will not allow calls from its own IP address...



        In your error it says "_singleton/admin/session" already exists so at least have a look at Mage registry key "_singleton/admin/session" already exists



        I don't have enough information but I think you may be trying to retrieve the products with the administrator role and your test.php is on the same host as your magento installation that you are questioning and you may have issues with IP restriction...






        share|improve this answer













        What role are you using to retrieve the products? Administrator, Customer or Guest? And are you running the test.php on the same host as the magento installation you are trying to reach? It seems so from your code. If so, has the host IP restriction in place? This can mean it will not allow calls from its own IP address...



        In your error it says "_singleton/admin/session" already exists so at least have a look at Mage registry key "_singleton/admin/session" already exists



        I don't have enough information but I think you may be trying to retrieve the products with the administrator role and your test.php is on the same host as your magento installation that you are questioning and you may have issues with IP restriction...







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 12 '17 at 12:09









        IsoldeIsolde

        21617




        21617



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f194097%2finvalid-auth-bad-request-got-a-401-expected-http-1-1-20x-or-a-redirect-magent%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Sum ergo cogito? 1 nng

            三茅街道4182Guuntc Dn precexpngmageondP