Magento 1.x : Accessing Magento Rest Api as AdminRest Api - call custom rest api functionOAuth for REST API using PHPProper Mobile API Implementation for Magento?Magento's REST API responses claiming oauth_callback param is emptyhow to get the product details by rest API in Magento1.9?Magento Rest Api ErrorHow to use Magento 2 API?Simple Magento 2 rest API?Having issue with magento 1.9 with API handlingREST API Access Token Issues

When is one 'Ready' to make Original Contributions to Mathematics?

Taking advantage when HR forgets to communicate the rules

Howto display unicode character u2026 in terminal mode in emacs

Why is there paternal, for fatherly, fraternal, for brotherly, but no similar word for sons?

Do intermediate subdomains need to exist?

How predictable is $RANDOM really?

Is conquering your neighbors to fight a greater enemy a valid strategy?

Do I need transit visa for Dublin?

Removing polygon holes in OpenLayers

How to delete multiple process id of a single process?

is this a question or an affirmation?

Did William Shakespeare hide things in his writings?

Merge overlapped intervals in a list

PhD: When to quit and move on?

How to reclaim personal item I've lent to the office without burning bridges?

Is it acceptable that I plot a time-series figure with years increasing from right to left?

Better random (unique) file name

How did Einstein know the speed of light was constant?

Why do we need a bootloader separate from our application program in microcontrollers?

Was the 45.9°C temperature in France in June 2019 the highest ever recorded in France?

Are "confidant" and "confident" homophones?

Examples of fluid (including air) being used to transmit digital data?

How to say "just a precision" properly in English?

SIunitx error when using lighter weight



Magento 1.x : Accessing Magento Rest Api as Admin


Rest Api - call custom rest api functionOAuth for REST API using PHPProper Mobile API Implementation for Magento?Magento's REST API responses claiming oauth_callback param is emptyhow to get the product details by rest API in Magento1.9?Magento Rest Api ErrorHow to use Magento 2 API?Simple Magento 2 rest API?Having issue with magento 1.9 with API handlingREST API Access Token Issues






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








5















I am trying to access magento rest api with following script, but is uses default guest role to access, so I cannot access orders and other stuffs. How can I access Magento Rest api as admin.



<?php

$callbackUrl = "http://192.168.1.144/o2/api/rest/orders";
$temporaryCredentialsRequestUrl =
"http://192.168.1.144/o2/oauth/initiate?oauth_callback=" .
urlencode($callbackUrl);
$adminAuthorizationUrl = 'http://192.168.1.144/o2/admin/oAuth_authorize';
$accessTokenRequestUrl = 'http://192.168.1.144/o2/oauth/token';
$apiUrl = 'http://192.168.1.144/o2/api/rest';
$consumerKey = '**********************';
$consumerSecret = '**********************';

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: ' . $adminAuthorizationUrl . '?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/orders";
$oauthClient->fetch($resourceUrl);
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);

catch (OAuthException $e)
print_r($e);










share|improve this question
























  • are you sure you created an admin role for REST API in the backend?

    – Marius
    May 6 '15 at 11:44











  • Yeah, I have created one and assigned it to user

    – S. M. Shahinul Islam
    May 7 '15 at 6:15











  • @Alvi_1987 - do you recall how you resolved this?

    – TylersSN
    Nov 4 '15 at 17:41

















5















I am trying to access magento rest api with following script, but is uses default guest role to access, so I cannot access orders and other stuffs. How can I access Magento Rest api as admin.



<?php

$callbackUrl = "http://192.168.1.144/o2/api/rest/orders";
$temporaryCredentialsRequestUrl =
"http://192.168.1.144/o2/oauth/initiate?oauth_callback=" .
urlencode($callbackUrl);
$adminAuthorizationUrl = 'http://192.168.1.144/o2/admin/oAuth_authorize';
$accessTokenRequestUrl = 'http://192.168.1.144/o2/oauth/token';
$apiUrl = 'http://192.168.1.144/o2/api/rest';
$consumerKey = '**********************';
$consumerSecret = '**********************';

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: ' . $adminAuthorizationUrl . '?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/orders";
$oauthClient->fetch($resourceUrl);
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);

catch (OAuthException $e)
print_r($e);










share|improve this question
























  • are you sure you created an admin role for REST API in the backend?

    – Marius
    May 6 '15 at 11:44











  • Yeah, I have created one and assigned it to user

    – S. M. Shahinul Islam
    May 7 '15 at 6:15











  • @Alvi_1987 - do you recall how you resolved this?

    – TylersSN
    Nov 4 '15 at 17:41













5












5








5








I am trying to access magento rest api with following script, but is uses default guest role to access, so I cannot access orders and other stuffs. How can I access Magento Rest api as admin.



<?php

$callbackUrl = "http://192.168.1.144/o2/api/rest/orders";
$temporaryCredentialsRequestUrl =
"http://192.168.1.144/o2/oauth/initiate?oauth_callback=" .
urlencode($callbackUrl);
$adminAuthorizationUrl = 'http://192.168.1.144/o2/admin/oAuth_authorize';
$accessTokenRequestUrl = 'http://192.168.1.144/o2/oauth/token';
$apiUrl = 'http://192.168.1.144/o2/api/rest';
$consumerKey = '**********************';
$consumerSecret = '**********************';

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: ' . $adminAuthorizationUrl . '?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/orders";
$oauthClient->fetch($resourceUrl);
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);

catch (OAuthException $e)
print_r($e);










share|improve this question
















I am trying to access magento rest api with following script, but is uses default guest role to access, so I cannot access orders and other stuffs. How can I access Magento Rest api as admin.



<?php

$callbackUrl = "http://192.168.1.144/o2/api/rest/orders";
$temporaryCredentialsRequestUrl =
"http://192.168.1.144/o2/oauth/initiate?oauth_callback=" .
urlencode($callbackUrl);
$adminAuthorizationUrl = 'http://192.168.1.144/o2/admin/oAuth_authorize';
$accessTokenRequestUrl = 'http://192.168.1.144/o2/oauth/token';
$apiUrl = 'http://192.168.1.144/o2/api/rest';
$consumerKey = '**********************';
$consumerSecret = '**********************';

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: ' . $adminAuthorizationUrl . '?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/orders";
$oauthClient->fetch($resourceUrl);
$productsList = json_decode($oauthClient->getLastResponse());
print_r($productsList);

catch (OAuthException $e)
print_r($e);







magento-1 api rest role






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 27 at 9:44









Vivek Kumar

2,7632 gold badges7 silver badges32 bronze badges




2,7632 gold badges7 silver badges32 bronze badges










asked May 6 '15 at 7:45









S. M. Shahinul IslamS. M. Shahinul Islam

1265 bronze badges




1265 bronze badges












  • are you sure you created an admin role for REST API in the backend?

    – Marius
    May 6 '15 at 11:44











  • Yeah, I have created one and assigned it to user

    – S. M. Shahinul Islam
    May 7 '15 at 6:15











  • @Alvi_1987 - do you recall how you resolved this?

    – TylersSN
    Nov 4 '15 at 17:41

















  • are you sure you created an admin role for REST API in the backend?

    – Marius
    May 6 '15 at 11:44











  • Yeah, I have created one and assigned it to user

    – S. M. Shahinul Islam
    May 7 '15 at 6:15











  • @Alvi_1987 - do you recall how you resolved this?

    – TylersSN
    Nov 4 '15 at 17:41
















are you sure you created an admin role for REST API in the backend?

– Marius
May 6 '15 at 11:44





are you sure you created an admin role for REST API in the backend?

– Marius
May 6 '15 at 11:44













Yeah, I have created one and assigned it to user

– S. M. Shahinul Islam
May 7 '15 at 6:15





Yeah, I have created one and assigned it to user

– S. M. Shahinul Islam
May 7 '15 at 6:15













@Alvi_1987 - do you recall how you resolved this?

– TylersSN
Nov 4 '15 at 17:41





@Alvi_1987 - do you recall how you resolved this?

– TylersSN
Nov 4 '15 at 17:41










0






active

oldest

votes














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%2f66847%2fmagento-1-x-accessing-magento-rest-api-as-admin%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















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%2f66847%2fmagento-1-x-accessing-magento-rest-api-as-admin%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

Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림