Megento 2 stdClass Object ( [message] => Consumer is not authorized to access %resources [parameters]...
up vote
0
down vote
favorite
I have magento2.1 installed in my server under folder magento2. So base Url is
http://$domain/magento2/
After this I have created a new role as admin and under permission clicked All.Then I created a new user with username, password and other details. Then connected the new user to new role.
After that i call the admin/token by passing username and password as
$apiURL="http://".$domain."/magento2/index.php/rest/V1/integration/admin/token";
//parameters passing with URL
$data = array("username" => "username", "password" => "!pass");
$data_string = json_encode($data);
$ch = curl_init($apiURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));
print_r(curl_getinfo($ch));
$token = curl_exec($ch);
//decoding generated token and saving it in a variable
echo $token= json_decode($token,true);
This gave a token but on print the http_code it gives 0. I tried through Postman too.
dadtaqm9b5bjqr6tk35hj8b6iy8a6hou //token
Then i called the customer/me endpoint
$token= trim($token);
//Using above token into header
$headers = array("Authorization: Bearer ".$token,"Accept:application/json");
//API URL to get all Magento 2 modules
$requestUrl='http://'.$domain.'/magento2/index.php/rest/V1/customers/me';
$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//print_r(curl_getinfo($ch));
$result = curl_exec($ch);
//decoding result
$result= json_decode($result);
//printing result
print_r($result);
This gave output as
stdClass Object ( [message] => Consumer is not authorized to access %resources [parameters] => stdClass Object ( [resources] => self ) )
Any solution to this problem?
magento magento2
add a comment |
up vote
0
down vote
favorite
I have magento2.1 installed in my server under folder magento2. So base Url is
http://$domain/magento2/
After this I have created a new role as admin and under permission clicked All.Then I created a new user with username, password and other details. Then connected the new user to new role.
After that i call the admin/token by passing username and password as
$apiURL="http://".$domain."/magento2/index.php/rest/V1/integration/admin/token";
//parameters passing with URL
$data = array("username" => "username", "password" => "!pass");
$data_string = json_encode($data);
$ch = curl_init($apiURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));
print_r(curl_getinfo($ch));
$token = curl_exec($ch);
//decoding generated token and saving it in a variable
echo $token= json_decode($token,true);
This gave a token but on print the http_code it gives 0. I tried through Postman too.
dadtaqm9b5bjqr6tk35hj8b6iy8a6hou //token
Then i called the customer/me endpoint
$token= trim($token);
//Using above token into header
$headers = array("Authorization: Bearer ".$token,"Accept:application/json");
//API URL to get all Magento 2 modules
$requestUrl='http://'.$domain.'/magento2/index.php/rest/V1/customers/me';
$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//print_r(curl_getinfo($ch));
$result = curl_exec($ch);
//decoding result
$result= json_decode($result);
//printing result
print_r($result);
This gave output as
stdClass Object ( [message] => Consumer is not authorized to access %resources [parameters] => stdClass Object ( [resources] => self ) )
Any solution to this problem?
magento magento2
1
It may duplicated magento.stackexchange.com/questions/150190/…
– Jared Chu
20 hours ago
I went through the link. no success.
– Logita Kurrey
17 hours ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have magento2.1 installed in my server under folder magento2. So base Url is
http://$domain/magento2/
After this I have created a new role as admin and under permission clicked All.Then I created a new user with username, password and other details. Then connected the new user to new role.
After that i call the admin/token by passing username and password as
$apiURL="http://".$domain."/magento2/index.php/rest/V1/integration/admin/token";
//parameters passing with URL
$data = array("username" => "username", "password" => "!pass");
$data_string = json_encode($data);
$ch = curl_init($apiURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));
print_r(curl_getinfo($ch));
$token = curl_exec($ch);
//decoding generated token and saving it in a variable
echo $token= json_decode($token,true);
This gave a token but on print the http_code it gives 0. I tried through Postman too.
dadtaqm9b5bjqr6tk35hj8b6iy8a6hou //token
Then i called the customer/me endpoint
$token= trim($token);
//Using above token into header
$headers = array("Authorization: Bearer ".$token,"Accept:application/json");
//API URL to get all Magento 2 modules
$requestUrl='http://'.$domain.'/magento2/index.php/rest/V1/customers/me';
$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//print_r(curl_getinfo($ch));
$result = curl_exec($ch);
//decoding result
$result= json_decode($result);
//printing result
print_r($result);
This gave output as
stdClass Object ( [message] => Consumer is not authorized to access %resources [parameters] => stdClass Object ( [resources] => self ) )
Any solution to this problem?
magento magento2
I have magento2.1 installed in my server under folder magento2. So base Url is
http://$domain/magento2/
After this I have created a new role as admin and under permission clicked All.Then I created a new user with username, password and other details. Then connected the new user to new role.
After that i call the admin/token by passing username and password as
$apiURL="http://".$domain."/magento2/index.php/rest/V1/integration/admin/token";
//parameters passing with URL
$data = array("username" => "username", "password" => "!pass");
$data_string = json_encode($data);
$ch = curl_init($apiURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Content-Length: ".strlen($data_string)));
print_r(curl_getinfo($ch));
$token = curl_exec($ch);
//decoding generated token and saving it in a variable
echo $token= json_decode($token,true);
This gave a token but on print the http_code it gives 0. I tried through Postman too.
dadtaqm9b5bjqr6tk35hj8b6iy8a6hou //token
Then i called the customer/me endpoint
$token= trim($token);
//Using above token into header
$headers = array("Authorization: Bearer ".$token,"Accept:application/json");
//API URL to get all Magento 2 modules
$requestUrl='http://'.$domain.'/magento2/index.php/rest/V1/customers/me';
$ch = curl_init($requestUrl);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//print_r(curl_getinfo($ch));
$result = curl_exec($ch);
//decoding result
$result= json_decode($result);
//printing result
print_r($result);
This gave output as
stdClass Object ( [message] => Consumer is not authorized to access %resources [parameters] => stdClass Object ( [resources] => self ) )
Any solution to this problem?
magento magento2
magento magento2
asked 20 hours ago
Logita Kurrey
268
268
1
It may duplicated magento.stackexchange.com/questions/150190/…
– Jared Chu
20 hours ago
I went through the link. no success.
– Logita Kurrey
17 hours ago
add a comment |
1
It may duplicated magento.stackexchange.com/questions/150190/…
– Jared Chu
20 hours ago
I went through the link. no success.
– Logita Kurrey
17 hours ago
1
1
It may duplicated magento.stackexchange.com/questions/150190/…
– Jared Chu
20 hours ago
It may duplicated magento.stackexchange.com/questions/150190/…
– Jared Chu
20 hours ago
I went through the link. no success.
– Logita Kurrey
17 hours ago
I went through the link. no success.
– Logita Kurrey
17 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53370749%2fmegento-2-stdclass-object-message-consumer-is-not-authorized-to-access-r%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
It may duplicated magento.stackexchange.com/questions/150190/…
– Jared Chu
20 hours ago
I went through the link. no success.
– Logita Kurrey
17 hours ago