# How can I change token endpoint url in AuthenticationAPIClient

**URL:** <https://community.auth0.com/t/how-can-i-change-token-endpoint-url-in-authenticationapiclient/182495>\
**Category:** Get Help\
**Tags:** auth0-android, sdks-quickstarts\
**Created:** [February 20, 2025, 1:00pm UTC](https://community.auth0.com/t/how-can-i-change-token-endpoint-url-in-authenticationapiclient/182495 "2025-02-20T13:00:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anil-k-s](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/anil-k-s/32/73080_2.png) [@anil-k-s](https://community.auth0.com/u/anil-k-s)\
**Post date:** [February 20, 2025, 1:00pm UTC](https://community.auth0.com/t/how-can-i-change-token-endpoint-url-in-authenticationapiclient/182495/1 "2025-02-20T13:00:51Z")

</div>

In AuthenticationAPIClient we have following method

```auto
    public fun token(
        authorizationCode: String,
        codeVerifier: String,
        redirectUri: String
    ): Request<Credentials, AuthenticationException> {
        val parameters = ParameterBuilder.newBuilder()
            .setClientId(clientId)
            .setGrantType(ParameterBuilder.GRANT_TYPE_AUTHORIZATION_CODE)
            .set(OAUTH_CODE_KEY, authorizationCode).set(REDIRECT_URI_KEY, redirectUri)
            .set("code_verifier", codeVerifier)
            .asDictionary()
        val url = auth0.getDomainUrl().toHttpUrl().newBuilder()
            .addPathSegment(OAUTH_PATH)
            .addPathSegment(TOKEN_PATH)
            .build()
        val credentialsAdapter: JsonAdapter<Credentials> = GsonAdapter(
            Credentials::class.java, gson
        )
        val request = factory.post(url.toString(), credentialsAdapter)
        request.addParameters(parameters)
        return request
    }

```

How can I remove .addPathSegment(OAUTH\_PATH) here as my token endpoint does not have this path segment.

Thanks  
Anil

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [February 26, 2025, 10:37pm UTC](https://community.auth0.com/t/how-can-i-change-token-endpoint-url-in-authenticationapiclient/182495/3 "2025-02-26T22:37:19Z")

</div>

Hi @anil-k-s,

Welcome to the Auth0 Community!

In general, your token endpoint should point to the `/oauth/token` token URL. You mentioned that your token endpoint does not have this path segment.

I recommend ensuring the request looks something like the following:

```auto
curl --request POST \
  --url 'https://{yourDomain}/oauth/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=authorization_code \
  --data 'client_id={yourClientId}' \
  --data 'client_secret={yourClientSecret}' \
  --data 'code=yourAuthorizationCode}' \
  --data 'redirect_uri={https://yourApp/callback}'

```

(Reference: [Call Your API Using the Authorization Code Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow/call-your-api-using-the-authorization-code-flow))

I can see that you are trying to perform the [Authorization Code flow](https://auth0.com/docs/api/authentication#authorization-code-flow). Which in Auth0, passes the authorization code to the [/oauth/token](https://auth0.com/docs/api/authentication#get-token47) endpoint to get your tokens.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 12, 2025, 10:37pm UTC](https://community.auth0.com/t/how-can-i-change-token-endpoint-url-in-authenticationapiclient/182495/4 "2025-03-12T22:37:30Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
