Error while trying out Apigee maven plugins for deployment with oauth options

Not applicable

Hi,

I am executing the steps as mentioned at: https://github.com/apigee/apigee-deploy-maven-plugin

Our Apigee Edge instance is deployed on a AWS server and we are having a separate SSO server.

I was trying out the apigee-edge-maven-plugin for deployment. None of the options are working.

I tried the following options:

mvn install -Pdevelopment -Dusername=myusername -Dpassword=mypassword -Dorg=myorg -Dauthtype=oauth -Dmfatoken=<mfa_token_obtained_from_https://*******.login.apigee.com/passcode> -X

mvn install -Pdevelopment -Dusername=myusername -Dpassword=mypassword -Dorg=myorg -Dtokenurl=https://*******.login.apigee.com/oauth/token -Dauthtype=oauth -X

mvn install -Pdevelopment -Dusername=myusername -Dpassword=mypassword -Dorg=myorg -Dtokenurl=https://********.login.apigee.com/oauth/token -Dauthtype=oauth -Dmfatoken=<mfa_token_obtained_from_https://*******.login.apigee.com/passcode> -X

For above request I see the following kind of error:

[ERROR] I/O error on POST request for "https://******.login.apigee.com/oauth/token": Connection timed out: connect; nested exception is java.net.ConnectException: Connection timed out: connect

Following is the stack trace for timeout error:

[INFO] ------------------------------------------------------------------------

[ERROR] Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.1.5:deploy (deploy-bundle) on project APIProxyToTestMavenDeployment: MojoExecutionException: connect timed out -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.apigee.build-tools.enterprise4g:apigee-edge-maven-plugin:1.1.5:deploy (deploy-bundle) on project APIProxyToTestMavenDeployment:

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)

at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)

at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)

at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)

at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)

at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)

at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)

at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)

at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)

at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)

at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)

at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)

at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Caused by: org.apache.maven.plugin.MojoExecutionException:

at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.processHelpfulErrorMessage(DeployMojo.java:385)

at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.execute(DeployMojo.java:370)

at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)

at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)

... 19 more

Caused by: java.net.SocketTimeoutException: connect timed out

at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)

at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)

at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)

at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

at java.net.Socket.connect(Socket.java:589)

at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)

at sun.net.NetworkClient.doConnect(NetworkClient.java:175)

at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)

at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)

at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)

at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)

at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)

at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138)

at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032)

at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)

at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1316)

at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1291)

at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)

at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:79)

at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:895)

at io.apigee.buildTools.enterprise4g.rest.RestUtil.executeAPI(RestUtil.java:930)

at io.apigee.buildTools.enterprise4g.rest.RestUtil.uploadBundle(RestUtil.java:453)

at io.apigee.buildTools.enterprise4g.rest.RestUtil.uploadBundle(RestUtil.java:421)

at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.doImport(DeployMojo.java:159)

at io.apigee.buildTools.enterprise4g.mavenplugin.DeployMojo.execute(DeployMojo.java:339)

... 21 more

I tried other requests using the bearer token (obtained using get_token):

mvn install -Pdevelopment -Dusername=myusername -Dorg=myorg -Dauthtype=oauth -Dtokenurl=https://*******.login.apigee.com/oauth/token -Dbearer=<access_token_generated_from_get_token> -X

Following are the example requests:

mvn install -Pdevelopment -Dusername= myusername -Dorg=myorg -Dauthtype=oauth -Dtokenurl=https://********.login.apigee.com/oauth/token -Dbearer=eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiIyNzcxNjBkNi04NTBhLTQ0ODgtODA0My02MjY0YzEyZTc4MDEiLCJzdWIiOiJjZjg4NDYyNi0zYWM1LTRjNTMtYjBkMS05OTFhODViNGI5MzMiLCJzY29wZSI6WyJzY2ltLmVtYWlscy5yZWFkIiwic2NpbS5tZSIsIm9wZW5pZCIsInBhc3N3b3JkLndyaXRlIiwiYXBwcm92YWxzLm1lIiwic2NpbS5pZHMucmVhZCIsIm9hdXRoLmFwcHJvdmFscyJdLCJjbGllbnRfaWQiOiJlZGdlY2xpIiwiY2lkIjoiZWRnZWNsaSIsImF6cCI6ImVkZ2VjbGkiLCJn******************************************************************************************** -X

mvn install -Pdevelopment -Dusername= myusername -Dorg=myorg -Dauthtype=oauth -Dtokenurl=https://*********.login.apigee.com/oauth/token -Dbearer=eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiIyNzcxNjBkNi04NTBhLTQ0ODgtODA0My02MjY0YzEyZTc4MDEiLCJzdWIiOiJjZjg4NDYyNi0zYWM1LTRjNTMtYjBkMS05OTFhODViNGI5MzMiLCJzY29wZSI6WyJzY2ltLmVtYWlscy5yZWFkIiwic2NpbS5tZSIsIm9wZW5pZCIsInBhc3N3b3JkLndyaXRlIiwiYXBwcm92YWxzLm1lIiwic2NpbS5pZHMucmVhZCIsIm9hdXRoLmFwcHJvdmFscyJdLCJjbGllbnRfaWQiOiJlZGdlY2xpIiwiY2lkIjoiZWRnZWNsaSIsImF6cCI6ImVkZ2VjbGkiLCJ************************************************************************ -Drefresh=eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI0YjNjNjFmMS1jMDlmLTQ3NTUtODc2Zi02NzVkYjg0NTQzYjEtciIsInN1YiI6ImNmODg0NjI2LTNhYzUtNGM1My1iMGQxLTk5MWE4NWI0YjkzMyIsInNjb3BlIjpbInNjaW0uZW1haWxzLnJlYWQiLCJzY2ltLm1lIiwib3BlbmlkIiwicGFzc3dvcmQud3JpdGUiLCJhcHByb3ZhbHMubWUiLCJzY2ltLmlkcy5yZWFkIiwib2F1dGguYXBwcm92YWxzIl0sImlhdCI6MTUwMDU5OTM4MiwiZXhwIjoxNTAzMTkxMzgyLCJjaWQiOiJlZGdlY2xpIiwiY2xpZW50X2lkIjoiZWRnZWNsaSIsImlzcyI6Imh0dHBzOi8vdmEubG9naW4uYXBpZ2VlLmNvbSIsInppZCI6InZhIiwiZ3JhbnRfdHlwZSI6InBhc3N3b3******************************************************************* -X

For the token related attempts it giving following errors:

[INFO] Access token not valid so acquiring new access token using Refresh Token

11:11:37,898 ERROR MgmtAPIClient:161 - Refresh Token could be invalid or expired: I/O error on POST request for "https://********.login.apigee.com/oauth/token": Connection timed out: connect; nested exception is java.net.ConnectException: Connection timed out: connect

[ERROR] I/O error on POST request for "https://********.login.apigee.com/oauth/token": Connection timed out: connect; nested exception is java.net.ConnectException: Connection timed out: connect

[ERROR]

Whereas, when I use get_token, same URL is working fine:

++ curl -s -d grant_type=password -d qp_responseType -d passcode=xnheEh https://********.login.apigee.com/oauth/token --header 'Content-Type: application/x-www-form-urlencoded;charset=utf-8' -H 'accept: application/json;charset=utf-8' -H 'authorization: Basic ZWRnZWNsaTplZGdlY2xpc2VjcmV0' --silent

I get a proper response.

From the same machine and same setup get_token and acurl are working perfectly fine.


What could be the issue with the plugin?


Thanks,

Sanjay


0 2 1,100
2 REPLIES 2

Not applicable

Rectified:

Options related to the mfa token are:

mvn install -Pdevelopment -Dusername=myusername -Dpassword=mypassword -Dorg=myorg -Dauthtype=oauth -Dmfatoken={mfa_token_obtained_from_https://*******.login.apigee.com/passcode} -X

mvn install -Pdevelopment -Dusername=myusername -Dpassword=mypassword -Dorg=myorg -Dtokenurl=https://********.login.apigee.com/oauth/token -Dauthtype=oauth -Dmfatoken= {mfa_token_obtained_from_https://*******.login.apigee.com/passcode} -X

Not applicable

For the timeout exception, I discovered that I need to pass system properties like this:

$ mvn clean deploy -P development -Dhttps.proxyHost="proxy_host" -Dhttps.proxyPort="proxy_port" -Dhttps.proxyUsername="my_username" -Dhttps.proxyPassword="my_password"

So while using the token I need to use the -Dapigee.bearer property. It works like this:

$ mvn clean deploy -P development -Dhttps.proxyHost="proxy_host" -Dhttps.proxyPort="proxy_port" -Dhttps.proxyUsername="my_username" -Dhttps.proxyPassword="my_password" -Dapigee.username='apigee_username_mailId' -Dapigee.bearer='access_token_from_get_token'

Many thanks to Niels Bertram for helping me out with the bearer token stuff.