Open octapudus opened 4 years ago
Hi,
You try to pass the Revolut code without authenticate your Revolut access. In your code, you get the Authorization Url. You should use it to redirect the visitor to the Revolut Authorization form.
Hope this could help.
require "vendor/autoload.php"; $authProvider = new \RevolutPHP\Auth\Provider([ 'clientId' => 'BLABLABLAmyid', // As shown when uploading your key 'privateKey' => 'blablabla/pathto my private key/privatekey.pem', 'redirectUri' => 'web link that i indicated into public key', // The URL to redirect the user to after the authorisation step 'isSandbox' => true ]);
Here is the most important thing
if($_GET["code"]=='') { $url = $authProvider->getAuthorizationUrl(); header("location:".$url); // This header will redirect the user if you didn't get Revolut code through GET. }
$accessToken = $authProvider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]);
Not exacly. Because i did all step by step indication..
Can you make the step by step instrusction? Beetween installing software and setting things into revolut business account? Because nlw its not too much clean. And you are the only one person with this kind of libraries.
Thank you
Hi, you should follow instructions described and test my solution.
Regards
Please permit me to show the problem by telegram. Please contact. Thank you
I don't use telegram sorry, but i can support you here.
Ok sorry it was only for real time problem solving.
By the way. I created the certificates. I created the key inside business account.
I get all the staff as you described. But it still get that error and i don't understand where is the problem.
Are you sure that there wasn'ylt any change into revolut rules about part of key management that could give me some kind of errors?
Because i saw they implemented a new staff like json web token. Is it implemented in your library?
I am discovering the library actually. What i can say is that your error is due to this line :
$accessToken = $authProvider->getAccessToken('authorization_code', ['code' => $_GET['code']
That's simple. Your variable is not set if you don't have ?code=xxxxxxxxxxxxxx in your URL.
If you want my code working, you have to set the REQUEST URI in your Revolut account to be the same as your php webpage. I don't know exactly if it is a good practice, as i am discovering the library.
In my account, my request URI is https://mywebsite.com/revolut/oauth.php The code i give you is located to this page. That should work if you do the same, but i encounter an issue reloading this webpage with the code passed in URL (i opened a ticket).
I'm sure a developper could help us regarding this problem.
Uhm. I send it to not exactly a file. But direction which send me to the index.php But maybe that is the problem
I go to sleep now. Please check this chat in the next days. I will create a dedicated file like whatever.php
And will see
Please try this code, it should output an URL. Copy this URL in your browser. Or tell me if you get any error.
require "vendor/autoload.php"; $authProvider = new \RevolutPHP\Auth\Provider([ 'clientId' => 'BLABLABLAmyid', // As shown when uploading your key 'privateKey' => 'blablabla/pathto my private key/privatekey.pem', 'redirectUri' => 'web link that i indicated into public key', // The URL to redirect the user to after the authorisation step 'isSandbox' => true ]); echo $url = $authProvider->getAuthorizationUrl();
Ok i try it now
You may access Revolut Authentification webpage. Connect to your account, and input your sms code. In case of success, you may be redirected to your request URI set in your Revolut Business account.
If you get an error, just copy the last line of your apache or nginx apache log here.
on running that code i have a blank page:
let me show you, i just gonna change my domain due to the privacy reasons: only domain will be changed (and also some characters of key)
this is the link after sms. (as you see i sent it to direction "amministrazione" so to index of that direction. https://mydomain.com/amministrazione/?code=oa_prod_qbFSGdBw6ZD9pTStDHpLO4lMq4Zn8YJn_gnUW5M3SSQ&state=
than i run into https://mydomain.com/payments/ this code
require "vendor/autoload.php";
$authProvider = new \RevolutPHP\Auth\Provider([ 'clientId' => 'kX0mpaJdri-IB6zhtUGHNJFZeV6rWtWEw1DY6FacRQM', // As shown when uploading your key 'privateKey' => 'file:///var/www/www-root/data/www/mydomanin.com/payments/test/privatekey.pem', 'redirectUri' => 'https://mydomanin.com/amministrazione/', // The URL to redirect the user to after the authorisation step 'isSandbox' => false ]); $url = $authProvider->getAuthorizationUrl();
and nothing happn
Just add “echo” before $url. And hide your client id it’s better 😉
Le lun. 9 mars 2020 à 02:59, octapudus notifications@github.com a écrit :
on running that code i have a blank page:
let me show you, i just gonna change my domain due to the privacy reasons: only domain will be changed (and also some characters of key)
this is the link after sms. (as you see i sent it to direction "amministrazione" so to index of that direction.
https://mydomain.com/amministrazione/?code=oa_prod_qbFSGdBw6ZD9pTStDHpLO4lMq4Zn8YJn_gnUW5M3SSQ&state=
than i run into https://mydomain.com/payments/ this code
require "vendor/autoload.php";
$authProvider = new \RevolutPHP\Auth\Provider([ 'clientId' => 'kX0mpaJdri-IB6zhtUGHNJFZeV6rWtWEw1DY6FacRQM', // As shown when uploading your key 'privateKey' => 'file:///var/www/www-root/data/www/ mydomanin.com/payments/test/privatekey.pem', 'redirectUri' => 'https://mydomanin.com/amministrazione/', // The URL to redirect the user to after the authorisation step 'isSandbox' => false ]); $url = $authProvider->getAuthorizationUrl();
and nothing happn
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sverraest/revolut-php/issues/11?email_source=notifications&email_token=AOYVHC743CBNKYH7UHPAVLLRGRER3A5CNFSM4K73LDT2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOFMXSI#issuecomment-596298697, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOYVHC7ZCUWVO262TZ6PLK3RGRER3ANCNFSM4K73LDTQ .
yeah sure, i put random digits of the same lenght, it's not mine client id :)
but the way now i see, there is the link. (again with random digits that i will put) so answer is https://business.revolut.com/app-confirm?state=74d5560826a85a966153893fa2c95c03&scope=READ&response_type=code&approval_prompt=auto&redirect_uri=https%3A%2F%2Fmydomanin.com%2Famministrazione%2F&client_id=kX0mpaJdri-IB6zhtUGHNJFZeas5rWtWEw1DYa3w65QM
now im trying to take the access token which i need in order to access to my account.
than the errors starts:
$accessToken = $authProvider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]);
tice: Undefined index: code in /var/www/www-root/data/www/mydomain.com/payments/index.php on line 53
Fatal error: Uncaught BadMethodCallException: Required parameter not passed: "code" in /var/www/www-root/data/www/mydomain.com/payments/vendor/league/oauth2-client/src/Tool/RequiredParameterTrait.php:35 Stack trace: #0 /var/www/www-root/data/www/mydomain.com/payments/vendor/league/oauth2-client/src/Tool/RequiredParameterTrait.php(53): League\OAuth2\Client\Grant\AbstractGrant->checkRequiredParameter('code', Array) #1 /var/www/www-root/data/www/mydomain.com/payments/vendor/league/oauth2-client/src/Grant/AbstractGrant.php(76): League\OAuth2\Client\Grant\AbstractGrant->checkRequiredParameters(Array, Array) #2 /var/www/www-root/data/www/mydomain.com/payments/vendor/league/oauth2-client/src/Provider/AbstractProvider.php(535): League\OAuth2\Client\Grant\AbstractGrant->prepareRequestParameters(Array, Array) #3 /var/www/www-root/data/www/mydomain.com/payments/vendor/vdbelt/oauth2-revolut/src/Provider/Revolut.php(144): League\OAuth2\Client\Provider\AbstractProvider->getAccessToken(Object(League\OAuth2\Client\Grant\AuthorizationCode), Array) #4 /v in /var/www/www-root/data/www/mydomain.com/payments/vendor/league/oauth2-client/src/Tool/RequiredParameterTrait.php on line 35
can you just share your code please? @Cyrilouletouriste
Hey i set everything as you described, i think.
///php code
require "vendor/autoload.php";
$authProvider = new \RevolutPHP\Auth\Provider([ 'clientId' => 'BLABLABLAmyid', // As shown when uploading your key 'privateKey' => 'blablabla/pathto my private key/privatekey.pem', 'redirectUri' => 'web link that i indicated into public key', // The URL to redirect the user to after the authorisation step 'isSandbox' => true ]);
$url = $authProvider->getAuthorizationUrl();
$accessToken = $authProvider->getAccessToken('authorization_code', [ 'code' => $_GET['code'] ]);
but still it's giving this error: i will hide my path to the privacy reasons with "*myDirectoryToSourceCOde**"
Fatal error: Uncaught BadMethodCallException: Required parameter not passed: "code" in *myDirectoryToSourceCOde**vendor/league/oauth2-client/src/Tool/RequiredParameterTrait.php:35 Stack trace: #0 *myDirectoryToSourceCOde**vendor/league/oauth2-client/src/Tool/RequiredParameterTrait.php(53): League\OAuth2\Client\Grant\AbstractGrant->checkRequiredParameter('code', Array) #1 *myDirectoryToSourceCOde**vendor/league/oauth2-client/src/Grant/AbstractGrant.php(76): League\OAuth2\Client\Grant\AbstractGrant->checkRequiredParameters(Array, Array) #2 *myDirectoryToSourceCOde**vendor/league/oauth2-client/src/Provider/AbstractProvider.php(535): League\OAuth2\Client\Grant\AbstractGrant->prepareRequestParameters(Array, Array) #3 *myDirectoryToSourceCOde**vendor/vdbelt/oauth2-revolut/src/Provider/Revolut.php(144): League\OAuth2\Client\Provider\AbstractProvider->getAccessToken(Object(League\OAuth2\Client\Grant\AuthorizationCode), Array) #4 /v in *myDirectoryToSourceCOde**vendor/league/oauth2-client/src/Tool/RequiredParameterTrait.php on line 35