I am trying to sending a POST REST call per the instructions here: https://developers.google.com/identity/protocols/OAuth2WebServer#handlingresponse (the section following the phrase "After the web server receives the authorization code, it can exchange the authorization code for an access token."). I keep getting 400 Bad Request thrown back at me. Here are the formatting motifs I tried (numbers in curly braces are parameters): {{code: '{1}', client_id: '{2}', client_secret: '{3}', redirect_uri: '{4}', grant_type: 'authorization_code'} {{'code': '{1}', 'client_id': '{2}', 'client_secret': '{3}', 'redirect_uri': '{4}', 'grant_type': 'authorization_code'} code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7& client_id=8819981768.apps.googleusercontent.com& client_secret={client_secret}& redirect_uri=https://oauth2.example.com/code& grant_type=authorization_code Any suggestions on what might be wrong? Also, just in case - I'm calling the MF from Deeplink. Here's the stack track showing the REST error propagating through the Deeplink MFs: com.mendix.core.CoreException: com.mendix.modules.microflowengine.MicroflowException: Error calling REST service at FunnelIntegration.DL_ReceiveGoogleAccessCode (CallRest : 'Call REST (POST)') at {"name":"DeepLink.ExecuteDeeplink","type":"JavaAction"} at DeepLink.DeepLinkHome (JavaAction : 'ExecuteDeeplink') at DeepLink.Home_Desktop_Default (SubMicroflow : 'DeepLinkHome') Advanced stacktrace: at com.mendix.core.component.InternalCore.execute(InternalCore.java:365) Caused by: com.mendix.modules.microflowengine.MicroflowException: Error calling REST service at FunnelIntegration.DL_ReceiveGoogleAccessCode (CallRest : 'Call REST (POST)') at {"name":"DeepLink.ExecuteDeeplink","type":"JavaAction"} at DeepLink.DeepLinkHome (JavaAction : 'ExecuteDeeplink') at DeepLink.Home_Desktop_Default (SubMicroflow : 'DeepLinkHome') Advanced stacktrace: at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:47) Caused by: com.mendix.modules.microflowengine.MicroflowException: 400: Bad Request at FunnelIntegration.DL_ReceiveGoogleAccessCode (CallRest : 'Call REST (POST)') at {"name":"DeepLink.ExecuteDeeplink","type":"JavaAction"} at DeepLink.DeepLinkHome (JavaAction : 'ExecuteDeeplink') at DeepLink.Home_Desktop_Default (SubMicroflow : 'DeepLinkHome') Advanced stacktrace: at com.mendix.integration.actions.microflow.RestCallAction.checkStatusCode(RestCallAction.scala:68) at com.mendix.integration.actions.microflow.RestCallAction.com$mendix$integration$actions$microflow$RestCallAction$$handleResponse(RestCallAction.scala:60) at com.mendix.integration.actions.microflow.RestCallAction$$anonfun$execute$1$$anonfun$apply$1.apply(RestCallAction.scala:42) at com.mendix.integration.actions.microflow.RestCallAction$$anonfun$execute$1$$anonfun$apply$1.apply(RestCallAction.scala:41) at com.mendix.integration.util.InputStreamUtil$.using(InputStreamUtil.scala:36) at com.mendix.integration.actions.microflow.RestCallAction$$anonfun$execute$1.apply(RestCallAction.scala:41) at com.mendix.integration.actions.microflow.RestCallAction$$anonfun$execute$1.apply(RestCallAction.scala:40) at com.mendix.integration.util.InputStreamUtil$.using(InputStreamUtil.scala:36) at com.mendix.integration.actions.microflow.RestCallAction.execute(RestCallAction.scala:40) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:172) at com.mendix.core.component.InternalCore.execute(InternalCore.java:363) at com.mendix.core.component.InternalCore.execute(InternalCore.java:374) at com.mendix.core.Core.execute(Core.java:213) at deeplink.actions.ExecuteDeeplink.executeAction(ExecuteDeeplink.java:99) at deeplink.actions.ExecuteDeeplink.executeAction(ExecuteDeeplink.java:1) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:172) at com.mendix.core.component.InternalCore.execute(InternalCore.java:390) at com.mendix.modules.microflowengine.actions.actioncall.JavaAction.execute(JavaAction.scala:52) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:172) at com.mendix.core.component.InternalCore.executeSync(InternalCore.java:472) at com.mendix.modules.microflowengine.actions.SubMicroflowAction.execute(SubMicroflowAction.scala:43) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:47) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:260) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:248) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:168) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:172) at com.mendix.core.component.InternalCore.execute(InternalCore.java:390) at com.mendix.webui.actions.microflow.GoHome$.go(ShowHomePageAction.scala:47) at com.mendix.webui.actions.client.GetSessionDataAction.execute(GetSessionDataAction.scala:84) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply$mcV$sp(ClientRequestHandler.scala:311) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:301) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:301) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(ActionDispatching.scala:143) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:36) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(ActionDispatching.scala:145) at scala.util.Try$.apply(Try.scala:192) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(ActionDispatching.scala:139) at akka.actor.Actor$class.aroundReceive(Actor.scala:465) at com.mendix.core.session.Worker.aroundReceive(ActionDispatching.scala:135) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) at akka.actor.ActorCell.invoke(ActorCell.scala:487) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) at akka.dispatch.Mailbox.run(Mailbox.scala:220) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
asked
Matt Cha
4 answers
1
Hi Matt,
If you are trying to perform OAuth I would just use the module that already exists and supports google OAuth.
Is it just a copy/paste mistake or are the double curly brackets also in your request? The request in your question starts with '{{', while I would expect it to start with a single curly bracket '{' in order to be valid JSON.
Maybe you can try to manually test the request with a tool like Postman for some quicker debugging.