# OAuth2 Client for email notifications

**URL:** <https://forum.inductiveautomation.com/t/oauth2-client-for-email-notifications/98983>\
**Category:** General Discussion\
**Tags:** ignition81\
**Created:** [November 22, 2024, 12:08pm UTC](https://forum.inductiveautomation.com/t/oauth2-client-for-email-notifications/98983 "2024-11-22T12:08:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam\_Bermejo](https://avatars.discourse-cdn.com/v4/letter/s/e68b1a/32.png) [@Sam\_Bermejo](https://forum.inductiveautomation.com/u/Sam_Bermejo)\
**Post date:** [November 22, 2024, 12:08pm UTC](https://forum.inductiveautomation.com/t/oauth2-client-for-email-notifications/98983/1 "2024-11-22T12:08:52Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/f/cf343e653aa20158056b87182d972a8618497d86.png)

I have configured the email OAuth2 Profile for gmail.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/c/9cc53249bbf6262cd1e4cba8d7fa7c9938e4d3bb.png)

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/9/99627d50801b402470bc87eff5b0490ba73d6e8d.png)

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/4/04087be89b5e910c4720b9b13314cdd0fe65ecab.png)

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/9/f938ddd053546bdd3f9742950bd31b6331ce0851.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/b/1b5e8c81eb9c11c626e5bc24e969aa5723b7dc61.png)

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

```python
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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 22, 2024, 1:40pm UTC](https://forum.inductiveautomation.com/t/oauth2-client-for-email-notifications/98983/2 "2024-11-22T13:40:37Z")

</div>

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

Please see [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

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.
