Kegon Posted November 12, 2017 Share Posted November 12, 2017 Hi I am trying to develop a module to help list products in various situations. How do I generate a token for at direct product link with PS 1.7.x? I can't seem to find any examples that helps. I can generate tokens for customers and other stuff which works - and those tokens seems to be md5, but the tokens for AdminProducts seems to be another type of hash, like "HK5Z6KMpx_EP6-ykNM2Ju1QAkOqlFmskolAe3IXt8ss". Any help anyone? Thanks for your answer. Link to comment Share on other sites More sharing options...
Rail Balco Posted November 24, 2017 Share Posted November 24, 2017 Hi, did you succeed with your issue? I'm currently having very similar problem, as I need to send my token from AdminProducts to my custom controller and I always receive token validation error in response. Link to comment Share on other sites More sharing options...
Uff182 Posted August 31, 2018 Share Posted August 31, 2018 (edited) Hello, can anyone provide some informations on this subject? I saw some solutions similar to $tokenProducts = Tools::getAdminToken( 'AdminProducts'. (int)Tab::getIdFromClassName('AdminProducts'). (int)$this->context->employee->id ); but the code I receive is always different from the one i see in the url in my browser after the _token parameter: index.php/product/catalog?_token=DIFFERENT_CODE_HERE Edit: nevermind, have a look here. Edited August 31, 2018 by Uff182 (see edit history) 2 Link to comment Share on other sites More sharing options...
soduno Posted July 19, 2019 Share Posted July 19, 2019 (edited) And if somebody wondering how just to generate a token, you can use: Tools::getAdminTokenLite('AdminOrders') Edited July 19, 2019 by soduno (see edit history) 1 Link to comment Share on other sites More sharing options...
Bruno G Posted June 11, 2020 Share Posted June 11, 2020 (edited) I have a issue I am stuck on for 3 days now. I created a controller in a module (modulename/src/Controller) with the new Symfony system : class TestController extends FrameworkBundleAdminController { public static function getTest(){ return new JsonResponse("test); } } And then declared the route in routes.yml as following: getTest: path: mymodule/gettest methods: [GET] defaults: _controller: 'Mymodule\Controller\TestController::getTest' When I call the URI adminfolder/modules/mymodule/gettest everything works fine but ONLY if i have the token of the module list page "http://...../adminfolder/index.php/improve/modules/manage" The aim of this controller is to send a JSON response called by AJAX. The thing is I cant NEVER find how to generate the token. I have tried Tools::getAdminTokenLite('whatever'); with every possible thing (AdminModules, AdminModulesManage, ModuleController, etc etc etc) and I never get the same token as I see in the admin module list page and I can't find how to get it even from my back office admin module. The token itself doesn't even lpooks the same : I get tokens like ..8ee59a385ba5225cc52b.. with the Tools::getAdminTokenLite() method and the token in http://...../adminfolder/index.php/improve/modules/manage looks like LettERSOnLYWithCaps-a_CapsLowAnd1234_CAPSAND123. The only place I can find this token is in $_SESSION as a csrf_token, but as it appears in links of admin menu tab (when you click on "modules" tab), its taken from somewhere, but where ? Could you tell me how to get this token that I can use it to reach my endpoint from ajax please ? Edited June 11, 2020 by Bruno G (see edit history) Link to comment Share on other sites More sharing options...
mistrjirka Posted July 29, 2021 Share Posted July 29, 2021 Hi, did you resolved the issue? Link to comment Share on other sites More sharing options...
hhcj Posted October 26, 2021 Share Posted October 26, 2021 (edited) On 7/29/2021 at 12:29 PM, mistrjirka said: Hi, did you resolved the issue? For me this link was the solution http://nemops.com/prestashop-redirections/#.YXfQT55Bybh $link = $this->context->link->getAdminLink('AdminProducts'); This $link has token of URL Edited October 26, 2021 by hhcj (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now