DavLn Posted February 1, 2023 Share Posted February 1, 2023 I do everything in sandbox mode but I'm blocked at this part: RevolutPHP\Auth\Provider And I get this error: Undefined array key "code" Thank you in advance for your help and advice. This is the guide, i use (https://github.com/sverraest/revolut-php) Quote Link to comment https://forums.phpfreaks.com/topic/315865-problem-with-access-to-the-account/ Share on other sites More sharing options...
ginerjm Posted February 1, 2023 Share Posted February 1, 2023 But - where is the code? A lot of us are afraid (rightfully so) to click on posters links. Pick out the part of your code that is giving you this message and post it here in the <> tags(above) And be sure to tell us which line matches the error message line number. Quote Link to comment https://forums.phpfreaks.com/topic/315865-problem-with-access-to-the-account/#findComment-1605250 Share on other sites More sharing options...
DavLn Posted February 1, 2023 Author Share Posted February 1, 2023 (edited) <?php require("vendor/autoload.php"); //... $authProvider = new \RevolutPHP\Auth\Provider([ 'clientId' => '{clientId}', // As shown when uploading your key 'privateKey' => 'sk_F7PVCXsUUMlQpGRYz3lN1Yxd-KsGkdYbjVbFugwPoWkvvqGOukcnlajxTOS8mrNV', 'redirectUri' => 'pk_HiQdMyLEmjpHBnAemaaklQqatz2pTfzdJrRCEhn0rAVqrxZK', // The URL to redirect the user to after the authorisation step 'isSandbox' => true ]); // redirect the user to the authorization flow in the Revolut for Business app echo $url = $authProvider->getAuthorizationUrl(); // Authorized user -> authorization code against an access token $accessToken = $authProvider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]); ?> Sorry, I forgot to post my code, but the link is safe, it's a link to a tutorial on the API that I'm following. And the error is on line 14 Edited February 1, 2023 by DavLn Quote Link to comment https://forums.phpfreaks.com/topic/315865-problem-with-access-to-the-account/#findComment-1605252 Share on other sites More sharing options...
Barand Posted February 1, 2023 Share Posted February 1, 2023 When you run this script, are you putting a value for "code" in the query string? EG http://localhost/myscript.php?code=123 Check whether code exists before trying to access it if (isset($_GET['code']) { $accessToken = $authProvider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]); } else { // error - no code } Quote Link to comment https://forums.phpfreaks.com/topic/315865-problem-with-access-to-the-account/#findComment-1605253 Share on other sites More sharing options...
DavLn Posted February 2, 2023 Author Share Posted February 2, 2023 I tried to put a value in "code" but I got an endless list of errors...And I attached the list of errors I got putting a value in "code". This is the code : <?php require("vendor/autoload.php"); //... $authProvider = new \RevolutPHP\Auth\Provider([ 'clientId' => '{clientId}', // As shown when uploading your key 'privateKey' => 'sk_F7PVCXsUUMlQpGRYz3lN1Yxd-KsGkdYbjVbFugwPoWkvvqGOukcnlajxTOS8mrNV', 'redirectUri' => 'pk_HiQdMyLEmjpHBnAemaaklQqatz2pTfzdJrRCEhn0rAVqrxZK', // The URL to redirect the user to after the authorisation step 'isSandbox' => true ]); // redirect the user to the authorization flow in the Revolut for Business app // echo $url = $authProvider->getAuthorizationUrl(); // Authorized user -> authorization code against an access token if(isset($_GET['code'])){ $accessToken = $authProvider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]); } else{ // error - no code } ?> Quote Link to comment https://forums.phpfreaks.com/topic/315865-problem-with-access-to-the-account/#findComment-1605274 Share on other sites More sharing options...
kicken Posted February 3, 2023 Share Posted February 3, 2023 That error is telling you that the private key option is supposed to be a path to a file that contains the key. Presumable the redirectUri option should be a URL too not some random token. Quote Link to comment https://forums.phpfreaks.com/topic/315865-problem-with-access-to-the-account/#findComment-1605349 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.