
Questions: 23,676 //
Answers: 52,209 //
Contributing Members: 17,942
Is there anyway to configure the google-spreadsheets:oauth-callback-config to work with CloudHub's pre-configured exposed ports of 8081 and 8082 without having to open additional ports in CloudHub by setting up VPC?
CloudHub Dev Environment:
Mule ESB 3.9
JDK 1.8_161
Google Spreadsheet Connector 1.2.4
google-api/oauth-authoize API - http://myapp.clouhub.io/google-api/oauth-authorize callback API should be - http://myapp.cloudhub.io/oauth2callback
I've tried the following combinations already...
Domain: localhost; Local Port: 8083; Remote Port: 8083 --> Localhost refuses to connect. Refuses callback connection to http://localhost:8083/oauth2callback.
Domain: ${fullDomain}; Local Port: 8083; Remote Port: 8083 --> Cannot assign requested address (java.net.BindException) (org.mule.api.DefaultMuleException)
Domain: localhost; Local Port: 8082; Remote Port: 8082 --> Localhost refuses to connect. Refuses callback connection to http://localhost:8082/oauth2callback.
Domain: ${fullDomain}; Local Port: 8082; Remote Port: 8082 --> Cannot assign requested address (java.net.BindException) (org.mule.api.DefaultMuleException)
Note: ${fullDomain} should resolve to myapp.cloudhub.io.
Feb 15, 2018 at 07:19 PM, edoc answered with:
So I downloaded the open source code for the Google Spreadsheet Connector and noticed under GoogleSpreadSheetConnectorConfigDefinitionParser class file that there's a hidden bean property attribute on google-spreadsheets:oauth-callback-config. Hidden as in Anypoint Studio UI doesn't have a field attribute to define this field. You have to define this field directly in the Configuration XML. See the image below for example...
If this attribute is not defined, MuleSoft will attempt to create a http/s connector based on the google-spreadsheets:oauth-callback-config attributes for domain, localPort, and remotePort. Rather than having it create a new http/s connector, you can define the hidden attribute, "connector-ref", to reference your existing http/s listener config.
The following works with CloudHub...
<google-spreadsheets:config-with-oauth name="Google_Spreadsheets" consumerKey="${google.apiKey}" consumerSecret="${google.apiSecret}" doc:name="Google Spreadsheets">
<google-spreadsheets:oauth-callback-config domain="${google.domain}" localPort="${http.port}" remotePort="${google.remote.port}" path="oauth2callback" connector-ref="httpListenerConfig"/>
</google-spreadsheets:config-with-oauth>
Where the property placeholders are defined as follows... google.domain=myappname.cloudhub.io http.port=8081 (or whatever CloudHub defines it per networking guidelines) google.remote.port=80
httpListenerConfig is defined typically...
<http:listener-config name="httpListenerConfig" host="0.0.0.0" port="${http.port}" doc:name="HTTP Listener Configuration"/>
This solves my issue of creating too many http:listener-configs when CloudHub only allows 2 publicly exposed ports, 8081 with 80, and 8082 with 443.
Feb 15, 2018 at 09:54 AM, kevinj answered with:
Hi @edoc,
The embedded image is not visible. Disclaimer: I've not worked specifically with the googlesheets oauth callback before. However I hope some CloudHub pointers may help resolve the issue:
If you are using the full domain as you've described for the callback address then the port should be 80
or 443
, which CloudHub maps to port 8081
or 8082
of your application for HTTP or HTTPS respectively.
localhost
should not be used for apps hosted on CloudHub, use: 0.0.0.0
instead (but neither address should be passed to the remote party since they'll not be able to resolve that).
Any port other than 8081
and 8082
is not publicly (internet) accessible
In other words your HTTP(S) listener should probably be configured as: host="0.0.0.0" port="${http.port}|${https.port}"
The oauth callback config should probably be configured as: domain="http(s)://APPNAME.cloudhub.io" localPort="${http.port}|${https.port}"
Note: the pipe |
is not a valid syntax or property separator, I simply mean to illustrate one property or the other, depending whether you are using HTTP or HTTPS. Also please note for HTTPS on CloudHub you need to provide a keystore configuration with your app.
Hope this helps, with kind regards,
Kevin
Hi @kevinj ,
These pointers are helpful and in theory makes sense, but CloudHub and Google connector is not too happy with the following configuration...
domain="https://myapp.cloudhub.io"
localPort="8082"
remotePort="443"
Two errors provided... Error 1 Could not register object for key auto-generated-listener-config-0 (org.mule.api.registry.RegistrationException)
Error 2
Failed to stop Mule context
org.mule.api.lifecycle.LifecycleException: Failed to invoke lifecycle phase "stop" on object: org.mule.module.http.internal.request.DefaultHttpRequesterConfig@51e7e73d
at org.mule.lifecycle.phases.DefaultLifecyclePhase.applyLifecycle(DefaultLifecyclePhase.java:243)
at org.mule.lifecycle.RegistryLifecycleCallback.doApplyLifecycle(RegistryLifecycleCallback.java:108)
at org.mule.lifecycle.RegistryLifecycleCallback.onTransition(RegistryLifecycleCallback.java:78)
at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(AbstractLifecycleManager.java:146)
at org.mule.lifecycle.RegistryLifecycleManager.fireLifecycle(RegistryLifecycleManager.java:134)
at [truncated]
Sorry I couldn't be of more help, but glad you managed to solve it and thanks for posting an answer back that will help any others in the future!