I am having a persisting issue with the Paypal access token for the sandbox environment where I continually get the error,
Client error: `POST https://api.sandbox.paypal.com/v1/payments/billing-
agreements` resulted in a `401 Unauthorized` response:
{"error":"invalid_token","error_description":"Access Token not found in cache"}
I am not sure where to go as this is a new token that is being generated and used just prior to running the API call. Everything was working normal until this began giving me issues a couple of nights ago. It seems to return this error for about 30 minutes or so until the token begins working. My issue is that once I switch to the live version, I do not want there to be this error while the new token is "processing" as the tokens are going to automatically update (or doing whatever the issue is).
Any suggestions?
The issue ended up being with Laravel's configuration caching from the env file. I just ran php artisan config:cache and it fixed itself. I added to the command
Artisan::call('config:cache');
and this fixed all of my issues.
Related
I'm having an issue with Laravel and Guzzle. When ever I try this line of code with my external website 'violapractice.com' I get an error:
$res = $client->request('GET','http://violapractice.com/articles.json.php');
Client error: `GET http://violapractice.com/articles.json.php` resulted in a `406 Not Acceptable` response: <html><head><title>Error 406 - Not Acceptable</title><head><body><h1>Error 406 - Not Acceptable</h1><p>Generally a 406 e (truncated...)
I've tried requesting a none php file and get the same error:
$res = $client->request('GET','http://violapractice.com/test.html');
The odd thing is, if I use any other URL, like https://stackoverflow.com the GET request goes through with no issue.
Also, I tired using postman on http://violapractice.com/articles.json.php and it worked fine.
I've never experienced anything like this before. Ideas anyone?
In the end, I ended up turning off ModSecurity in the violapractice.com cpanel. I felt that the risk in doing this was minimal because the website is only accessible through admin login and has many layers of security.
Use case: VueJS/Laravel app has inventory. Calling Magento2 using SOAP API to update Qty from VueJS/Laravel.
Error as shared below:
Access to XMLHttpRequest at
'http://xx.yyy.abc.123/rest/V1/integration/admin/token?username=admin&password=xxxxx'
from origin 'http://192.168.0.x' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested
resource.
Note: I am a beginner in this domain. I might be asking stupid questions. Please bear with me and requesting help here.
Tools/Apps used:
Laravel Framework 7.9.2 /Running on http://192.168.0.x
VueJS /Running on http://192.168.0.x
Magento2 /Running on http://xx.yyy.abc.123
Postman (Tool used to test SOAP API)
Debugging efforts:
URL http://xx.yyy.abc.123/rest/V1/integration/admin/token?username=admin&password=xxxxx
Tried from postman: It works, Apended token into postmane and got the response.
Making AXIOS call from VueJS/Laravel application to Magento2:(Failed)
Origin: http://192.168.0.x
Magento2: http://xx.yyy.abc.123
axios.post("http://xx.yyy.abc.123/rest/V1/integration/admin/token?username=admin&password=xxxxx",
{
})
.then((response) =>
{
console.log("response.data",response.data);
this.apiResponse = response.data;
//this.getproduct();
})
.catch(error =>
{
alert('ERROR GETCATEGORY!!!! No Data found');
console.log(error.response);
});
Checked for 2 days now about CORS error and found that this is enabled by default in Laravel 7. Not sure why I am seeing this error even after using Laravel 7. There are very few answers or solutions specific to VueJS with Laravel 7.
Question:
What does this error means. I thought it is just calling from webpage1 to webpage2, it does not seem to work.
Do I need to make any changes on my VueJS/Laravel application. Am I missing anything further.
Please do let me know if you need any more information to help me in this regards.
Thanks for your help.
Regards,
I had got the same CORS error while working on a Vue.js project. I finally solved this issue just today in the morning. You can resolve this either by building a proxy server or another way would be to disable the security settings of your browser (eg, CHROME) for accessing cross origin apis. Both these solutions had worked for me. The later solution is the easiest solutoion and does not require any mock server or a proxy server to be build. Both these solutions can be resolved at the front end.
You can disable your browser (CHROME) security settings for accessing apis out of the origin by typing the below command on the terminal:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --user-data-dir="/tmp/chrome_dev_session" --disable-web-security
After running the above command on your terminal, a new chrome window with security settings disabled will open up. Now, run your program (npm run serve / npm run dev) again and this time you will not get any CORS error and would be able to GET request using axios.
Hope this helps!
We capture mobile device information along with jwt token generated for it and store it in mysql table.
This is ensure the user is able to use the app on 1 or more devices allocated for the user as per the plan.
There is situation where user logs out from the devices or we force the user to logout of the device by invalidating the token. In that case below code is executed to invalidate the jwt token.
try {
JWTAuth::manager()->invalidate(new \Tymon\JWTAuth\Token($token), $forceForever = false);
}
catch (JWTException $e) {
}
Below is tech stack
PHP 7.2
lumen
Redis
Below image shown error occurs only with this api and not any other Api's. Not sure why its throwing an error related to cache.
Seems like whenever sudo php artisan cache:clear is executed on server it starts to work and again from next day it fails.
please let me know whats the reason for it
my lumen was using local cache for some reason i forgot to change to redis which i was supposed to use. So now its fine.
We have three environments, Dev, QA and Prod.
We have a stable PHP running that connects with evernote , get token and fetch content.
we updated our QA environment to PHP 7.0 and now when via evernote when we try to fetch Token it returns
Invalid auth\/bad request (got a 411, expected HTTP\/1.1 20X or a redirect)
Here is the code
$oauth = new \OAuth($this->consumerKey, $this->consumerSecret);
return $oauth->getRequestToken($this->getEndpoint('oauth'), $callbackUrl);
I have checked that consumerKey etc and everything is correct.
I am not sure what error could be here since 411 is normally when you need to send content length, but in Evernote API they dont mention anything like this
Is this due to PHP 7.0 ?
Any help will be appreciated
Thanks
Yes, you probably need to send the content length.
Does Evernote change the API validation for the Content-Length?
I see there is another workaround proposed on Github.
I have the TwitterOAuth class and demonstration running on a local development server and I cannot get it to authorize. I have entered the new CONSUMER_KEY and CONSUMER_SECRET in the config.php. I have also synced the server time to NTP. I get the error message: 'Could not connect to Twitter. Refresh the page or try again later.'
var_dump($connection->http_code);
results:
int 0
ANY help or advise would be appreciated.
I am running PHP 5.3
When I try to ping the api server I can't.
C:\Users\Owner>ping api.twitter.com
Ping request could not find host api.twitter.com. Please check the name and try
again.
could this be the problem ?
I had some issues with this process as well. I don't exactly recall what resolved this error, but I followed This Tutorial (albeit a bit out of date) and made sure I explicitly set the callback URL in the twitter panel for my app. Also, and I believe this one also caused the int 0 return for me, make sure that if you are going with a hosting provider they allow CURL requests.
step 1: https://apps.twitter.com/app or go to your app setting
step 2: Unchecked the (Enable Callback Locking (It is recommended to enable callback locking to ensure apps cannot overwrite the callback url)) This box..
save and exit and check..
ThankYou..!