# Error while running oAuth middleware

**URL:** <https://forum.canton.network/t/error-while-running-oauth-middleware/6620>\
**Category:** App Development\
**Tags:** daml\
**Created:** [May 31, 2023, 10:50am UTC](https://forum.canton.network/t/error-while-running-oauth-middleware/6620 "2023-05-31T10:50:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rocky](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/rocky/32/833_2.png) [@Rocky](https://forum.canton.network/u/Rocky)\
**Post date:** [May 31, 2023, 10:50am UTC](https://forum.canton.network/t/error-while-running-oauth-middleware/6620/1 "2023-05-31T10:50:14Z")

</div>

Hello,

I am following [this link](https://docs.daml.com/tools/auth-middleware/oauth2.html#deployment-notes) to start the oAuth middleware after setting the required values, but i am getting below error message while running the command. Any idea what exactly is the issue?

daml oauth2-middleware --config /oauth-middleware.conf

daml-helper: Received ExitFailure 1 when running  
Raw command: java -Dlogback.configurationFile=/home/rocky/.daml/sdk/2.6.4/daml-sdk/oauth2-middleware-logback.xml -jar /home/rocky/.daml/sdk/2.6.4/daml-sdk/daml-sdk.jar oauth2-middleware --config /oauth-middleware.conf

---

<div class="post-metadata">

**Author:** ![bernhard](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bernhard/32/356_2.png) [@bernhard](https://forum.canton.network/u/bernhard)\
**Post date:** [May 31, 2023, 12:23pm UTC](https://forum.canton.network/t/error-while-running-oauth-middleware/6620/2 "2023-05-31T12:23:52Z")

</div>

What happens when you run this directly?

`java -Dlogback.configurationFile=/home/rocky/.daml/sdk/2.6.4/daml-sdk/oauth2-middleware-logback.xml -jar /home/rocky/.daml/sdk/2.6.4/daml-sdk/daml-sdk.jar oauth2-middleware --config /oauth-middleware.conf`

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [May 31, 2023, 1:05pm UTC](https://forum.canton.network/t/error-while-running-oauth-middleware/6620/3 "2023-05-31T13:05:06Z")

</div>

The path to your config file seems a bit weird - `/` is usually only writable by root. I suspect that path is wrong and that’s why the middleware is not starting.

It’s a bit unfortunate that it isn’t giving a more appropriate error message.

---

<div class="post-metadata">

**Author:** ![Rocky](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/rocky/32/833_2.png) [@Rocky](https://forum.canton.network/u/Rocky)\
**Post date:** [June 1, 2023, 6:13am UTC](https://forum.canton.network/t/error-while-running-oauth-middleware/6620/4 "2023-06-01T06:13:40Z")

</div>

I started the oauth2-middleware using cli-args as shown below

oauth2-middleware   
–callback [https://example.com/auth/cb](https://example.com/auth/cb)   
–address 0.0.0.0   
–http-port 3265   
–oauth-auth [https://oauth2-provider.com/auth\_uri](https://oauth2-provider.com/auth_uri)   
–oauth-token [https://oauth2-provider.com/token\_uri](https://oauth2-provider.com/token_uri)   
–auth-jwt-rs256-jwks [https://example.com/.well-known/jwks.json](https://example.com/.well-known/jwks.json)

In console it shows

12:45:41.324 [main] WARN com.daml.auth.middleware.oauth2.Cli - Using cli opts for running oauth2-middleware is deprecated  
12:45:41.611 [system-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started  
12:45:42.292 [system-akka.actor.default-dispatcher-8] INFO c.daml.auth.middleware.oauth2.Main$ - Started server: ServerBinding(/0.0.0.0:3265)

My question is, how would i test endpoints in postman, I dont see any logs in the console when i hit below URL in postman-  
/auth?claims=actAs:Alice+applicationId:MyApp

---

<div class="post-metadata">

**Author:** ![Rocky](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/rocky/32/833_2.png) [@Rocky](https://forum.canton.network/u/Rocky)\
**Post date:** [June 1, 2023, 2:01pm UTC](https://forum.canton.network/t/error-while-running-oauth-middleware/6620/5 "2023-06-01T14:01:41Z")

</div>

Just an update i am able to hit the endpoint using the postman. But getting below response. Any inputs on this. How to resolve it?

**Authentication is possible but has failed or not yet been provided.**

Below is the endpoint i am trying  
[http://localhost:3121/auth?claims=actAs:Alice+applicationId:MyApp](http://localhost:3121/auth?claims=actAs:Alice+applicationId:MyApp)

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [June 1, 2023, 2:10pm UTC](https://forum.canton.network/t/error-while-running-oauth-middleware/6620/6 "2023-06-01T14:10:44Z")

</div>

Hi @Rocky,

I’m unfortunately not very familiar with either Postman or the OAuth2 Middleware, so I’m not in a great position to help you. I’ll try to find someone who might be a better fit.

---

<div class="post-metadata">

**Author:** ![Carl\_Pulley](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/carl_pulley/32/5138_2.png) [@Carl\_Pulley](https://forum.canton.network/u/Carl_Pulley)\
**Post date:** [June 2, 2023, 2:55pm UTC](https://forum.canton.network/t/error-while-running-oauth-middleware/6620/7 "2023-06-02T14:55:08Z")

</div>

Hi @Rocky,

Just had a quick look over the Scala code to see if I can understand your observations within a code context.

- Top level middleware routes are defined at [daml/Server.scala at cfc499fbb69f916c54f2fcb5c8094291a3b8faf0 · digital-asset/daml · GitHub](https://github.com/digital-asset/daml/blob/cfc499fbb69f916c54f2fcb5c8094291a3b8faf0/triggers/service/auth/src/main/scala/com/daml/auth/middleware/oauth2/Server.scala#L291-L319)

- The claims parameters are managed at [daml/Server.scala at cfc499fbb69f916c54f2fcb5c8094291a3b8faf0 · digital-asset/daml · GitHub](https://github.com/digital-asset/daml/blob/cfc499fbb69f916c54f2fcb5c8094291a3b8faf0/triggers/service/auth/src/main/scala/com/daml/auth/middleware/oauth2/Server.scala#L95-L112)

In order for the `/auth` endpoint to provide an authorised response, we need:

- a valid access token to be supplied
- and for that token to provide the requested claims.

As you are observing a response that appears to be consistent with an unauthorised response, I currently feel this might be the issue being displayed here?

As I was digging around, I did note that there’s some helpful looking notes in the file [daml/README.md at cfc499fbb69f916c54f2fcb5c8094291a3b8faf0 · digital-asset/daml · GitHub](https://github.com/digital-asset/daml/blob/cfc499fbb69f916c54f2fcb5c8094291a3b8faf0/triggers/service/auth/src/main/scala/com/daml/auth/middleware/oauth2/README.md). Hopefully these might help you out further here?

Hope that helps,

Carl.

---

<div class="post-metadata">

**Author:** ![bernhard](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bernhard/32/356_2.png) [@bernhard](https://forum.canton.network/u/bernhard)\
**Post date:** [June 5, 2023, 7:03am UTC](https://forum.canton.network/t/error-while-running-oauth-middleware/6620/8 "2023-06-05T07:03:15Z")

</div>

> [@Rocky](#):
>
> oauth2-middleware  
> –callback [https://example.com/auth/cb](https://example.com/auth/cb)  
> –address 0.0.0.0  
> –http-port 3265  
> –oauth-auth [https://oauth2-provider.com/auth\_uri](https://oauth2-provider.com/auth_uri)  
> –oauth-token [https://oauth2-provider.com/token\_uri](https://oauth2-provider.com/token_uri)  
> –auth-jwt-rs256-jwks [https://example.com/.well-known/jwks.json](https://example.com/.well-known/jwks.json)

[example.com](http://example.com) and [oauth2-provider.com](http://oauth2-provider.com) here are placeholders. If you haven’t done so, you need to populate all the URLs with real ones corresponding to your application (in place of [example.com](http://example.com)) and your token provider (in place of [oauth2-provider.com](http://oauth2-provider.com). Eg use Auth0).
