Google auth2.0 won't work when send request from Google Composer - google-api

I am running sample code from google document, everything works fine in local. I put http://localhost under the Authorized redirect URIs so I am able to authenticate from the browser and get results (calendar event) back. I have converted the code into an airflow dag:
from airflow import DAG, macros
from airflow.operators.python import PythonOperator
from utils.aircal_utils import sync_tp_gcalendar, test_from_local
with DAG(
"update_calendar",
default_args={"start_date": macros.datetime(2022, 10, 9, 22, 0, tzinfo=TZ)},
) as dag:
task = PythonOperator(task_id="update_calender",
python_callable=main) # main function from example
task
And test the dag from the composer. I got same authentication request inlog. After authenticate from browser, I get error:
This site can’t be reachedlocalhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
I have tried to add composer domain in to Authorized redirect URI but it seems that google doesn't allow google service provided domain. Error as: Invalid Redirect: uses a forbidden domain. Similar error found in google bug tracker but it seems to be an intended behavior. Does anyone know how can I successfully run the code in google composer?

Related

Laravel response differs when using Amazon ELB - use case: AirBnB ical Importer

Background: We are using Laravel v8.83.5 running on nginx and PHP 7.4 Amazon Linux EC2 instance which is powered by an Elastic Load Balancer. We provide an iCalendar feed as a URL to customers which they can import into AirBNB, VRBO and other OTA.
Issue:
When our iCal Feed URL is added to VRBO, it's accepted and parsed by it.
When we use our iCal Feed URL on AirBNB, it throws an error 'We're having trouble syncing this calendar. Try importing it again.'. The same URL downloads an .ics file when visited from the browser and also works when importing into another iCal compatible calendar. The syntax is valid as has been checked on https://icalendar.org/validator.html as well.
To identify the issue,
we tried a different URL on another Digital Ocean server which returns the same response but does not have an ELB behind it and also uses nginx and php 7.4. That URL is accepted by the AirBnB importer. A screenshot of the response headers for this second server's request is attached here
A screenshot of the response headers for which the request fails on AirBNB is attached here.
When trying via postman, both requests return the same response content. The general headers are same as well.
On checking nginx access logs, the response code return to AirBNB by the servers is 200 in both cases.
If we pass a static file into the AirBNB importer from the server that's behind the ELB, the URL works on AirBNB.
We have tried
disabling gzip and cache control in nginx on the response being returned.
switching between apache and nginx on the server that sits behind the Amazon ELB.
Removed all global middleware added by Laravel on that route

Go gmail api quickstart results in localhost refused to connect ERR_CONNECTION_REFUSED

I'm following the steps in go quickstart gmail api.
On the function getTokenFromWeb, pasting either the long url
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=abcdefg.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fgmail.readonly&state=state-token
or
http://localhost:8000
results in
This site can't be reached. localhost refused to connect. ERR_CONNECTION_REFUSED
Following the same quickstart but for python works flawlessly.
If I get the token via python and use it in Go quickstart, it also works. So the issue is just on the token from web retrieval.
The issue you are having is related to the removal of oob. When that sample was originally created oob still worked. So it would display a nice web page for you where you could copy the authorization code.
That no longer works so we are forced to use http://127.0.0.1 or localhost. As your machine apparently does not have a web server running its displaying to you a 404 error.
However if you look in the URL bar you will find the authorization code you need in order to authorize your application.
The solution is to simply copy the code from the url bar. If you want to fix the 404 your going to have to figure out how to start a web server in order to host the http://127.0.0.1 from.
The python sample does this by running a local server
creds = flow.run_local_server(port=0)
Php can do it using something like this
php -S localhost:8000 -t examples/
Im not sure how that can be done with Go though.

What is the request that whatsapp cloud api does to verify a webhook?

I'm able to verify the webhook using glitch from the getting started:
https://glitch.com/edit/?fbclid=IwAR2YTjZuGGM9Hi6T_v1eZh_nV6_HY3RYn_8lll4gY1REa_bJy6ZAuq6tkKQ#!/whatsapp-cloud-api-echo-bot
my local server (in a subdomain with https enabled) has the same behavior as glitch and show "WEBHOOK_VERIFIED" on the log for the request:
/webhook?hub.mode=subscribe&hub.verify_token=xpto123&hub.challenge=123
but when try to verify my local server the request from meta does not reach the server.
chrome showing that the connection to the server is secured
After more tests I found that my local server was been blocked by the ISP, understood it after test with another connection.
I made my own server and had tried ngrok and other programs to run it from local host with https redirect but whatsapp doesn't allow the use of those programs.
In the end, my error was that the URL HAS to end in /webhook or else, it won't even send the request. Then it'll send a GET request and you have to return the hub.challenge query param after making sure that the provided token from them is the one you set up. This is my code using NodeJS
if(req.query['hub.verify_token'] === process.env.VERIFY_TOKEN) return res.status(200).send(req.query['hub.challenge'])

Laravel Paypal payment execute working on localhost but not on remote server

I am using laravel as a backend and vue as front end while integrating paypal. The integration works locally and the payment process works. But when I tried to go live, it give folowing errors
Access to XMLHttpRequest at 'https://www.example.com/myApi/api/execute-payment/' from origin 'https://www.example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
POST https://www.example.com/myApi/api/execute-payment/ net::ERR_FAILED
Uncaught Error: Request to post https://www.example.com/myApi/api/execute-payment/ failed: [object ProgressEvent]. Correlation id: null
at XMLHttpRequest.xhrError (http.js:123)**
I have already handled Cors on the backend. I have tried using Cors google extension on local server (hitting the live endpoints) but the execute payment method does not return to my url instead keep loading (executing and executing) which does not seem to stop.
I have not changed the paypal environemnt to 'production' on the client side though because of testing purpose.
Also the payment creation (createPayment) flow works fine on live server. It just gives this error after I login to paypal account and click pay (to start payment execution).
Kindly Help me. Thank you.

CORS request did not succeed

I have a problem when I want to create an authentication system using VueJs as the frontend (http://localhost:8080/#/login) and Laravel 5.6 as the backend. When I try to submit login form using the api login url http://127.0.0.1:8000/api/v1/login, I get the error message:
Cross-Origin Request Blocked: The Same Origin Policy disallows
reading the remote resource at http://127.0.0.1:8000/api/v1/login.
(Reason: CORS request did not succeed).
I don't know how to solve this problem.
Could anyone here help me to solve my problem?
NOTE : I have to install laravel-cors before
This is an old question, but I'll reply nonetheless.
For me this error was caused by a self-signed certificate. If you open developer tools, select the network tab, click the call that failed CORS you can see the security tab. Click it to open it. If a cert is giving you problems the text "An error occurred: SEC_ERROR_INADEQUATE_KEY_USAGE" should be visible.
To resolve this just go to the URL that gave you the CORS error, and accept the cert manually.
Cross Origin Resource Sharing is a mechanism that uses additional HTTP headers to tell a browser to allow the web application running on one origin (client) have permission to access selected resources from a server at a different origin.
Basically, your Vue app (http://localhost:8080) needs to be allowed access to your Laravel endpoint (http://127.0.0.1:8000/api/v1/login) This is to prevent me from hitting your Laravel endpoint from my malicious website and acting like an authenticated user.
Based on the docs, you need to add 'allowedOrigins' => ['*'], but that means you're opening up your backend to all requests. That's fine if it's a public API but in this context it doesn't sound like you want that. Instead, in this case it would be 'allowedOrigins' => ['localhost:8080'], so that your Vue app can consume your Laravel server.
You have to use either localhost or 127.0.0.1 for all the requests. In general in your code you should make calls to the server by just appending the URI to the current host, without re-adding the host and port in the URI string. If you load your page from a given host, for example 127.0.0.1 and then try to make an AJAX request to another host, for example www.host.com, the request gets blocked to prevent XSS attacks
It sounds like you are running this in dev mode via webpack currently? If that is correct and your workflow is that you are going to build the Vue application and have it co-reside with your Laravel backend then you just need to update config/index.js to have a proxyTable entry that forwards webpack requests to the correct dev Laravel backend server.
This would look something like this.
module.exports = {
dev: {
proxyTable: {
"/": "http://127.0.0.1:8000/api/v1/login"
}
}
}
There is additional information available on how this works; https://vuejs-templates.github.io/webpack/proxy.html
I was stuck with this error recently while I was trying to get one of our old websites hosted via Azure (App Services) up and running again.
Reason: CORS request did not succeed was the error showing in the browser console, however, it turned that for our case the URL mentioned in the CORS error doesn't exist anymore - its referring to the old https://******.azurewebsites.net service url we had (previous hosted in Azure - App Services).
So also check that the URL mentioned in the CORS-error is in fact working.
In my case the computer was not displaying the correct date and time. When I try to view the page I would get the "CORS request did not succeed." Once I updated to the correct time and date the page displayed normally.
I had to change the base URL of axios. I didn't notice it was https://, not http://
file: src\store\index.js
change the
axios.defaults.baseURL = 'https://127.0.0.1:8000/api'
to
axios.defaults.baseURL = 'http://127.0.0.1:8000/api'
Note: Make sure it's exactly same URL and Port. You can see that in terminal where you start the laravel application (php artisan serve).

Resources