OAuth2 Client for email notifications

Hi all,

I'm struggling to create an OAuth2 Client working. It's the first time I create one, so please bear with me while I explain all the steps I have taken. I'm using Ignition 8.1.37. How can I get this working?? Thank you in advance.

I have the client created in ignition.

I have configured the email OAuth2 Profile for gmail.

The First issue I encounter is that the access token seems to be invalid.

I have tested the authorization and it seems to be ok.

I then test the token, and that is also working.

And when I test the email server, this is the issue I'm getting.

java.lang.IllegalStateException: Unable to get a valid OAuth2 access token

at com.inductiveautomation.ignition.gateway.mail.smtp.OAuth2SmtpEmailProfile.getAuthCredential(OAuth2SmtpEmailProfile.java:100)

at com.inductiveautomation.ignition.gateway.mail.smtp.AbstractSmtpEmailProfile.doSendEmail(AbstractSmtpEmailProfile.java:168)

at com.inductiveautomation.ignition.gateway.mail.smtp.AbstractSmtpEmailProfile.sendEmail(AbstractSmtpEmailProfile.java:71)

at com.inductiveautomation.ignition.gateway.mail.EmailProfileManagerImpl$RunningEmailProfile.sendEmail(EmailProfileManagerImpl.java:455)

at com.inductiveautomation.ignition.gateway.web.pages.config.TestEmailProfilePanel$1.onSubmitInternal(TestEmailProfilePanel.java:61)

at com.inductiveautomation.ignition.gateway.web.components.CsrfPreventingForm.onSubmit(CsrfPreventingForm.java:66)

at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1310)

at org.apache.wicket.markup.html.form.Form.process(Form.java:967)

at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:789)

at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:701)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.base/java.lang.reflect.Method.invoke(Unknown Source)

at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)

at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)

at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:243)

at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:236)

at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:890)

at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)

at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261)

at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218)

at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289)

at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259)

at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201)

at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:282)

at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:210)

at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635)

at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:527)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131)

at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:578)

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)

at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:223)

at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1570)

at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:221)

at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1384)

at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)

at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)

at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1543)

at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)

at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1306)

at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)

at com.inductiveautomation.catapult.handlers.RemoteHostNameLookupHandler.handle(RemoteHostNameLookupHandler.java:121)

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)

at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:301)

at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:51)

at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:141)

at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)

at org.eclipse.jetty.server.Server.handle(Server.java:563)

at org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:505)

at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:762)

at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:497)

at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)

at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)

at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)

at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)

at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:416)

at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:385)

at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:272)

at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.lambda$new$0(AdaptiveExecutionStrategy.java:140)

at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:411)

at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)

at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)

at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)

at java.base/java.lang.Thread.run(Unknown Source)

Caused by: java.util.concurrent.TimeoutException: null

at java.base/java.util.concurrent.CompletableFuture.timedGet(Unknown Source)

at java.base/java.util.concurrent.CompletableFuture.get(Unknown Source)

at com.inductiveautomation.ignition.gateway.mail.smtp.OAuth2SmtpEmailProfile.getAuthCredential(OAuth2SmtpEmailProfile.java:92)

... 65 common frames omitted

How can I get this working?? Thank you in advance.

First, please edit your post and fix the formatting of the exception traceback:

Please see Wiki - how to post code on this forum.

Second, buried in that traceback is a connection timeout error. You have a network problem, not yet an auth problem. Find out why the target is dropping/ignoring the request.