softwaremill / softwaremill/tapir

Specify audience in Oauth 2.0 Client Credentials flow

Open
#4,663 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.5k
Forks
468
Avg merge
5h 37m
Merged PRs (30d)
34

Description

Hi, I'm trying to test the built in securityIn with client credentials flow but getting an error because I haven't specified an audience on this server I set up in auth0.

  val oauthToken = apiEndpoint
    .in("oauth" / "client")
    .securityIn(auth.oauth2.clientCredentialsFlow("https://<omitted>.us.auth0.com/oauth/token"))
    .out(stringBody)

curL created by Tapir/Swagger

curl 'https://<omitted>.us.auth0.com/oauth/token' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'authorization: Basic <omitted>' \
  -H 'content-type: application/x-www-form-urlencoded' \
  -H 'dnt: 1' \
  -H 'origin: http://localhost:8083' \
  -H 'priority: u=1, i' \
  -H 'referer: http://localhost:8083/' \
  -H 'sec-ch-ua: "Chromium";v="137", "Not/A)Brand";v="24"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: cross-site' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36' \
  -H 'x-requested-with: XMLHttpRequest' \
  --data-raw 'grant_type=client_credentials'

Auth0's sample request on how they want it to look like.

curl --request POST \
  --url https://<omitted>.us.auth0.com/oauth/token \
  --header 'content-type: application/json' \
  --data '{
    "client_id":"<omitted>",
    "client_secret":".<omitted>",
    "audience":"https:/<omitted>.us.auth0.com/api/v2/",
    "grant_type":"client_credentials"
  }'

Right now I'm getting this error in my Swagger:

Image

EDIT: I can get around this by specifying a default audience in Auth0 but this question is still relevant.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the securityIn call using oauth2.clientCredentialsFlow and compare its generated request with the Auth0 sample in the issue. Determine how an audience can be supplied for the client-credentials flow, then verify that the generated request includes it and that existing usage remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api, authentication
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.