# Problem about POST https://api.eu.nylas.com/v3/connect/token request

**URL:** <https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291>\
**Category:** Question and Answers\
**Tags:** authentication\
**Created:** [July 24, 2024, 1:49pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291 "2024-07-24T13:49:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![efeengin](https://avatars.discourse-cdn.com/v4/letter/e/3e96dc/32.png) [@efeengin](https://forums.nylas.com/u/efeengin)\
**Post date:** [July 24, 2024, 1:49pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/1 "2024-07-24T13:49:26Z")

</div>

Hello everyone.  
I am using v3 api and getting **code** from previous Oauth Request.  
then I am making connect/token request to get grant\_id to save.

I am always getting **“error\_code”:45004,“error\_description”:“Code verifier challenge failed”**

I create code verifier than making a challenge from it . method is either plain or s256 it fails.

I thought I am making a mistake when creating PKCE

I used another library to validate my own verifier and challenge

[https://github.com/AdrienGras/pkce-php](https://github.com/AdrienGras/pkce-php) it validates.

any ideas what to do ?

thanks for help in advance.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [July 24, 2024, 2:31pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/2 "2024-07-24T14:31:22Z")

</div>

@efeengin just wondering what platform did you specify for hosted authenciation?

 ![Screenshot 2024-07-24 at 10.30.51 AM](https://us1.discourse-cdn.com/flex015/uploads/nylas3/original/1X/9fec479aa30aff1424d341b228ec3642243ae7cc.png)

For frontend authentication, it should be `JavaScript`

Also I created a reference code sample for PKCE using `nylas-identity`: [GitHub - nylas-samples/nylas-auth-flow-react-spa: Authentication Users Accounts in a Single Page Application / Mobile App](https://github.com/nylas-samples/nylas-auth-flow-react-spa)

---

<div class="post-metadata">

**Author:** ![efeengin](https://avatars.discourse-cdn.com/v4/letter/e/3e96dc/32.png) [@efeengin](https://forums.nylas.com/u/efeengin)\
**Post date:** [July 24, 2024, 3:30pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/3 "2024-07-24T15:30:57Z")

</div>

@ram it is website . to /auth endpoint I am making this request

```auto
client_id=exxxxxa&access_type=offline&login_hint=efexxxxxxx35%40gmail.com&prompt=select_provider&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fintegrations%2Fnylasv3-callback&code_challenge=ZTk2YmY2Njg2YTNjMzUxMGU5ZTkyN2RiNzA2OWNiMWNiYTliOTliMDIyZjQ5NDgzYTZjZTMyNzA4MDllNjhhMg&code_challenge_method=S256

```

then I am trying to get grant from /token endpoint with this request

```auto
 array:6 [▼
  "client_id" => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  "client_secret" => "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  "grant_type" => "authorization_code"
  "code" => "09w1xSghI6798E_0zXnIh1mBnsQYHvpqc7Btez3wCyLYMAHKq8_y74WXWTT0pg9GsTYD9Fn1N5qzD6iDHXiO3lM5LGbXIlUS"
  "redirect_uri" => "http://localhost/integrations/nylasv3-callback"
  "code_verifier" => "e96bf6686a3c3510e9e927db7069cb1cba9b99b022f49483a6ce3270809e68a2"
]

```

response : `error":"invalid_grant","error_code":45004,"error_description":"Code verifier challenge failed`

but getting code challenge is failed. I am doing everything in backend  
I need to get grant\_id and save from the last request and with api key I will consume endpoints.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [July 24, 2024, 8:13pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/5 "2024-07-24T20:13:48Z")

</div>

@efeengin for completing backend Auth, just curious is PKCE a requirement for your app?

Also want to share our Quickstart guide with built in authentication, we go over how to [Set up user auth with Nylas](https://developer.nylas.com/docs/v3/quickstart/email/#set-up-user-auth-using-nylas).

---

<div class="post-metadata">

**Author:** ![efeengin](https://avatars.discourse-cdn.com/v4/letter/e/3e96dc/32.png) [@efeengin](https://forums.nylas.com/u/efeengin)\
**Post date:** [July 24, 2024, 8:35pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/6 "2024-07-24T20:35:47Z")

</div>

no it is not but when I send request to /token and if I do not put code\_verifier . I get some error like " param code\_verifier is not sent etc "

---

<div class="post-metadata">

**Author:** ![efeengin](https://avatars.discourse-cdn.com/v4/letter/e/3e96dc/32.png) [@efeengin](https://forums.nylas.com/u/efeengin)\
**Post date:** [July 24, 2024, 8:41pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/7 "2024-07-24T20:41:28Z")

</div>

what I meant is. I send /auth without code\_challenge and code\_challenge\_method which is withOUT PKCE. then I get the code.

then I do 1 more request to /token to get grant\_id . if I do not send code\_verifier I get error. I believe something is broken with API. spent all day to try every combination still not good.

---

<div class="post-metadata">

**Author:** ![efeengin](https://avatars.discourse-cdn.com/v4/letter/e/3e96dc/32.png) [@efeengin](https://forums.nylas.com/u/efeengin)\
**Post date:** [July 24, 2024, 8:42pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/8 "2024-07-24T20:42:52Z")

</div>

and all other endpoints grant\_id/messages etc working really fine. just stuck in authentication.

---

<div class="post-metadata">

**Author:** ![Emmad\_Altaf](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@Emmad\_Altaf](https://forums.nylas.com/u/Emmad_Altaf)\
**Post date:** [July 25, 2024, 11:10am UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/9 "2024-07-25T11:10:03Z")

</div>

Hi @efeengin @ram ,  
I am also facing same issue from last two days, I am trying to exchange code but its giving me error that “Code verifier challenge failed”. I tried hard but its not resolving. I think there is an issue with api. If you got solution then please help me also. I am still stuck at this error.

---

<div class="post-metadata">

**Author:** ![efeengin](https://avatars.discourse-cdn.com/v4/letter/e/3e96dc/32.png) [@efeengin](https://forums.nylas.com/u/efeengin)\
**Post date:** [July 25, 2024, 11:51am UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/10 "2024-07-25T11:51:28Z")

</div>

@Emmad_Altaf I believe it is API issue cause I tried any combination with and without PKCE I got same error everything. in my first try I was able to get grant\_id so I moved to implement other endpoints after 5-6 hours when I try to auth other account . I got that error and it still exists.

---

<div class="post-metadata">

**Author:** ![efeengin](https://avatars.discourse-cdn.com/v4/letter/e/3e96dc/32.png) [@efeengin](https://forums.nylas.com/u/efeengin)\
**Post date:** [July 29, 2024, 6:21am UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/11 "2024-07-29T06:21:07Z")

</div>

@ram @Emmad_Altaf any progress cause I am still getting this error. I am pretty sure it is an API issue. Is there any [@admins](https://forums.nylas.com/groups/admins) who can look at thi issue?

---

<div class="post-metadata">

**Author:** ![Emmad\_Altaf](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@Emmad\_Altaf](https://forums.nylas.com/u/Emmad_Altaf)\
**Post date:** [July 29, 2024, 8:00am UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/12 "2024-07-29T08:00:18Z")

</div>

Hi @efeengin, I emailed Nylas support, and they asked me for details in their reply. I provided them with all the details last Friday. Hopefully, the Nylas team is looking into this issue. I am also waiting for the Nylas team to fix this issue as my work is currently halted because of it.

---

<div class="post-metadata">

**Author:** ![efeengin](https://avatars.discourse-cdn.com/v4/letter/e/3e96dc/32.png) [@efeengin](https://forums.nylas.com/u/efeengin)\
**Post date:** [July 29, 2024, 8:35am UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/13 "2024-07-29T08:35:12Z")

</div>

I am waiting this issue to be solved also.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [July 29, 2024, 3:21pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/14 "2024-07-29T15:21:23Z")

</div>

Hi, thanks for sharing your debugging steps - let me block some time to take a look at this soon.

---

<div class="post-metadata">

**Author:** ![efeengin](https://avatars.discourse-cdn.com/v4/letter/e/3e96dc/32.png) [@efeengin](https://forums.nylas.com/u/efeengin)\
**Post date:** [July 29, 2024, 7:48pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/15 "2024-07-29T19:48:08Z")

</div>

@ram any news? we really stuck here.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [July 29, 2024, 8:38pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/16 "2024-07-29T20:38:04Z")

</div>

@efeengin I’m going to try to authenticate using our [Quickstart Guide for Email](https://developer.nylas.com/docs/v3/quickstart/email/) as a test.

Can you confirm if you have tried running one of our [Quickstart Guides](https://developer.nylas.com/docs/v3/quickstart/) with your App credentials and the result? You can also just download the repository, and add your credentials, and run it.

Trying to determine where the issue is.

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [July 29, 2024, 8:52pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/17 "2024-07-29T20:52:05Z")

</div>

@efeengin @Emmad_Altaf

I was able to test out the following [Quickstart Guide](https://github.com/nylas-samples/quickstart-email-node) to authenticate and received a grant:

`{"message":"OAuth2 flow completed successfully for grant ID: GRANT_ID"}`

If you can try doing the same, we can futher debug where the issue is. All the code for authenticating is available in the [repository](https://github.com/nylas-samples/quickstart-email-node/blob/main/index.js) as well (and we have similar repos for other languages).

Alternatively, can you try creating a test grant (`Add test grant`) using our Dashboard? This uses our hosted authentication UI screen, but is another way to test auth is working for your application without code:

 ![Screenshot 2024-07-29 at 4.52.25 PM](https://us1.discourse-cdn.com/flex015/uploads/nylas3/original/1X/2c2ba6fdd13288f46d183ece3fa1c3215cab785f.png)

Another question - are you using our `sandbox` environment to test out Auth?

---

<div class="post-metadata">

**Author:** ![efeengin](https://avatars.discourse-cdn.com/v4/letter/e/3e96dc/32.png) [@efeengin](https://forums.nylas.com/u/efeengin)\
**Post date:** [July 30, 2024, 8:18am UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/18 "2024-07-30T08:18:05Z")

</div>

yes I am using nylas sandbox env to test oAuth

---

<div class="post-metadata">

**Author:** ![efeengin](https://avatars.discourse-cdn.com/v4/letter/e/3e96dc/32.png) [@efeengin](https://forums.nylas.com/u/efeengin)\
**Post date:** [July 30, 2024, 10:55am UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/19 "2024-07-30T10:55:57Z")

</div>

@ram funny thing is when I dont send any code\_challenge code\_challenge\_method. also code\_verifier for token endpoint

I get code verifier not provided error. so every request for me goes over PKCE

> {“error”:“invalid\_grant”,“error\_code”:45004,“error\_description”:“For code challenge check, code verifier not provided”,"

---

<div class="post-metadata">

**Author:** ![ram](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.nylas.com/ram/32/3_2.png) [@ram](https://forums.nylas.com/u/ram)\
**Post date:** [July 30, 2024, 1:26pm UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/20 "2024-07-30T13:26:57Z")

</div>

Hi @efeengin - can you try running one of our [quickstart guides](https://developer.nylas.com/docs/v3/quickstart/) to authenticate an account? I don’t suspect an API issue. Our quickstarts have all the code that you can compare across your application.

Also can you share what your Callback URIs are, I want to check the `Platform` field:

 ![Screenshot 2024-07-30 at 9.26.24 AM](https://us1.discourse-cdn.com/flex015/uploads/nylas3/original/1X/87a180d6eebde3fae4627e2429b4682b2e452fc2.png)

---

<div class="post-metadata">

**Author:** ![Emmad\_Altaf](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@Emmad\_Altaf](https://forums.nylas.com/u/Emmad_Altaf)\
**Post date:** [July 31, 2024, 10:02am UTC](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291/21 "2024-07-31T10:02:12Z")

</div>

Hi @ram ,  
Below are details:

Client Id: CLIENT\_ID  
API key: API\_KEY

**My application code methods - flow:**

codeVerifier: CODE\_VERIFIER

codeChallenge: CODE\_CHALLENGE

nylasHostUrl: [https://api.eu.nylas.com/v3/connect/auth?client\_id=20f1c644-c0b1-4c62-b6ac-0109aad8fcd6&redirect\_uri=http://localhost:43344/api/Integration/EmailAndCalendarMasterAccountCallback&response\_type=code&access\_type=online&provider=google&login\_hint=nylasv3@gmail.com&code\_challenge=Ak2HC08a01ywI1CohFcVgmIV6CX11OjMown\_Nvj7WdU&code\_challenge\_method=S256](https://api.eu.nylas.com/v3/connect/auth?client_id=20f1c644-c0b1-4c62-b6ac-0109aad8fcd6&redirect_uri=http://localhost:43344/api/Integration/EmailAndCalendarMasterAccountCallback&response_type=code&access_type=online&provider=google&login_hint=nylasv3@gmail.com&code_challenge=Ak2HC08a01ywI1CohFcVgmIV6CX11OjMown_Nvj7WdU&code_challenge_method=S256)

code: CODE

json: {“code”:“CODE”,“client\_id”:“20f1c644-c0b1-4c62-b6ac-0109aad8fcd6”,“client\_secret”:“API\_KEY”,“code\_verifier”:“CODE\_VERIFIER”,“redirect\_uri”:“[http://localhost:43344/api/Integration/EmailAndCalendarMasterAccountCallback",“grant\_type”:"authorization\_code](http://localhost:43344/api/Integration/EmailAndCalendarMasterAccountCallback%22,%22grant_type%22:%22authorization_code)”}

responce: {StatusCode: 401, ReasonPhrase: ‘Unauthorized’, Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:

{  
Connection: keep-alive  
X-Frame-Options: DENY  
X-Content-Type-Options: nosniff  
X-XSS-Protection: 1; mode=block  
x-kong-upstream-latency: 50  
Access-Control-Allow-Origin: \*  
Strict-Transport-Security: max-age=63072000; includeSubDomains  
Accept-Ranges: bytes  
Cache-Control: no-store  
x-kong-proxy-latency: 10  
x-unique-id: 1981e2a2-edf4-41ff-8e61-59e2fb22ca01  
Via: 1.1 varnish, 1.1 varnish  
Date: Fri, 26 Jul 2024 09:40:40 GMT  
X-Served-By: cache-qpg120109-QPG, cache-qpg120109-QPG  
X-Cache: MISS, MISS  
X-Cache-Hits: 0, 0  
X-Timer: S1721986840.087965,VS0,VE243  
Vary: Origin  
Content-Length: 203  
Content-Type: application/json  
}, Trailing Headers:  
{  
}}

responseString: {“error”:“invalid\_request\_error”,“error\_code”:401,“error\_description”:“client\_id is required”,“error\_uri”:“[Nylas Unified Auth Service API Reference](https://accounts.nylas.io/#tag/Event-Codes%22,%22request_id%22:%22321fd5a0-dac5-4ce3-a7ca-df93d640c9c1)”}

**Now I am also sharing PostMan call details:**

[https://api.eu.nylas.com/v3/connect/token](https://api.eu.nylas.com/v3/connect/token)

{

“code”:“CJiO7tK4x0A5IYRw1XNiYcJ-IXMGZkrWKi–XOkuZ8S9oo0GyxpgUeBW8KJb\_S5e5XC3IIP4X7dIgEzjKMvIP4-ttIP5X-YA”,

“client\_id”:“20f1c644-c0b1-4c62-b6ac-0109aad8fcd6”,

“client\_secret”:“CLIENT\_SECRET”,

“redirect\_uri”:“[http://localhost:43344/api/Integration/EmailAndCalendarMasterAccountCallback](http://localhost:43344/api/Integration/EmailAndCalendarMasterAccountCallback)”,

“grant\_type”:“authorization\_code”,

“code\_verifier”: “4ebk8Yi3piz7DVqayWFLd1HXX5YFlC4GmEKrphWftNU”

}

{

“error”: “invalid\_grant”,

“error\_code”: 45004,

“error\_description”: “Code verifier challenge failed”,

“error\_uri”: “[Nylas Unified Auth Service API Reference](https://accounts.nylas.io/#tag/Event-Codes)”,

“request\_id”: “ee26a152-6092-49a7-8550-c5d6b6e69f77”

}

![image.png](https://mail.google.com/mail/u/6?ui=2&ik=747154b37d&attid=0.1&permmsgid=msg-a:r-6343116732896790416&th=190ee783af70f767&view=fimg&fur=ip&sz=s0-l75-ft&attbid=ANGjdJ-iKIKEmuyY9jkTw-Frq1dMhUzBwLdDGlN8IGJNphZj5j18n0l1xruT-55vSBiLUwoYKNgD7wdjMcSzi-fE-kutjxQJcgQpPdCdepFLH148_xpRsnH-kmOgDAA&disp=emb&realattid=ii_lz2ilgl50)

![image.png](https://mail.google.com/mail/u/6?ui=2&ik=747154b37d&attid=0.2&permmsgid=msg-a:r-6343116732896790416&th=190ee783af70f767&view=fimg&fur=ip&sz=s0-l75-ft&attbid=ANGjdJ-pftRMpIYygtCZLCiC04vW724G_PjjHsUGVvqAO3rkmG2XBif-ov2H0IK78ePqCwPYZbWVP8KHcbaw5QeKC0YHmgEci8OCe_lmBY3dd2cuK22KHjiqkabJnSw&disp=emb&realattid=ii_lz2indjt1)

![image.png](https://mail.google.com/mail/u/6?ui=2&ik=747154b37d&attid=0.3&permmsgid=msg-a:r-6343116732896790416&th=190ee783af70f767&view=fimg&fur=ip&sz=s0-l75-ft&attbid=ANGjdJ-FuhAlU_KoTxb7Hp9c3GaoaJhEgAwZpk14AAcnD_QfEstSwybzkzRDcm_qEUEZEhw2Ia4GbPQ1EusFqBbczhiKTHFCogOXHCHuSmqvqPe195xZ1M4h3wnAH7I&disp=emb&realattid=ii_lz2io13t2)

If i try with my application then its asking that client id is required , you can check i have already correctly passed client id. But if we run flow in postman with same data then its asking that Code verifier challenge failed.

Please review this and investigate/test it in details - its always asking that “Code verifier challenge failed”, I believe this is api issue.

I am waiting for your quick fix please.

Thanks

[Next page](https://forums.nylas.com/t/problem-about-post-https-api-eu-nylas-com-v3-connect-token-request/291.md?page=2)
