# Exchange code for token CORS issue

**URL:** <https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407>\
**Category:** OAuth/OIDC\
**Created:** [February 21, 2023, 4:30pm UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407 "2023-02-21T16:30:08Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArtemBekh](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@ArtemBekh](https://devforum.okta.com/u/ArtemBekh)\
**Post date:** [February 21, 2023, 4:30pm UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/1 "2023-02-21T16:30:08Z")

</div>

We are building Authorization Code Flow with PKCE in Flutter. We do receive authorization code successfully.  
We added our Flutter app host to trusted source in default authorization server. We do all requests manually as there is no SDK for Flutter.  
Please, point us to the direction on how to fix this.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 21, 2023, 5:25pm UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/2 "2023-02-21T17:25:57Z")

</div>

Are you currently attempting to redirect the user to the /authorize endpoint to get the authorization code?

---

<div class="post-metadata">

**Author:** ![ArtemBekh](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@ArtemBekh](https://devforum.okta.com/u/ArtemBekh)\
**Post date:** [February 21, 2023, 5:37pm UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/3 "2023-02-21T17:37:57Z")

</div>

Hi Andrea. This part is done  
We are at step 6 now

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/1/1aa16b7fbf18377118006472e874457ae1c0ae95.png)

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 21, 2023, 6:34pm UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/4 "2023-02-21T18:34:06Z")

</div>

Are you having an issue making the /token request? If so, are you encountering any specific errors?

---

<div class="post-metadata">

**Author:** ![ArtemBekh](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@ArtemBekh](https://devforum.okta.com/u/ArtemBekh)\
**Post date:** [February 21, 2023, 7:06pm UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/5 "2023-02-21T19:06:21Z")

</div>

Right, request is returning token successfully when done via Postman.  
However, when making it from Flutter app we receive this CORS issue.

 ![image](https://global.discourse-cdn.com/oktadev/original/2X/9/9645056c111f4304f198983fa1dd897e45a1701a.png)  
 ![image](https://global.discourse-cdn.com/oktadev/original/2X/6/64fc79714a868a08a2a8be573e7bcbd4476f0f25.png)  
Here is sample request  
 ![Screenshot 2023-02-21 211211](https://global.discourse-cdn.com/oktadev/original/2X/3/31f2e3ce41a2116a74637fdf19bc6fdaaf1f3116.png)

---

<div class="post-metadata">

**Author:** ![Dima101397](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Dima101397](https://devforum.okta.com/u/Dima101397)\
**Post date:** [February 22, 2023, 11:41am UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/6 "2023-02-22T11:41:32Z")

</div>

Got same issue with **/token** endpoint in flutter

---

<div class="post-metadata">

**Author:** ![Dima101397](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Dima101397](https://devforum.okta.com/u/Dima101397)\
**Post date:** [March 2, 2023, 9:22am UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/7 "2023-03-02T09:22:09Z")

</div>

Do you find solution of the problem? I check doc about PCKE flow, and validate data. I don’t send client secret or smth like that, but still receive CORS for /token endpoint

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [March 2, 2023, 6:51pm UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/8 "2023-03-02T18:51:43Z")

</div>

Does the issue persist if you clear cache/cookies in the browser and retry? Are all users of this application affected or is it more environmental?

---

<div class="post-metadata">

**Author:** ![Dima101397](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Dima101397](https://devforum.okta.com/u/Dima101397)\
**Post date:** [March 3, 2023, 9:04am UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/9 "2023-03-03T09:04:12Z")

</div>

I try to clean cache and cookies and still face the issue with CORS. We just start implement OKTA SSO in Flutter with PKCE code and I start application local

---

<div class="post-metadata">

**Author:** ![Dima101397](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Dima101397](https://devforum.okta.com/u/Dima101397)\
**Post date:** [March 6, 2023, 3:35pm UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/10 "2023-03-06T15:35:45Z")

</div>

Do you have any solution or could you advice some packages for Flutter (we use flutter for web application) integration with OKTA?

---

<div class="post-metadata">

**Author:** ![Dima101397](https://avatars.discourse-cdn.com/v4/letter/d/e47774/32.png) [@Dima101397](https://devforum.okta.com/u/Dima101397)\
**Post date:** [March 9, 2023, 9:18am UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/11 "2023-03-09T09:18:36Z")

</div>

Find fix of issue. I reinstall flutter with flag that disable security. I event don’t know why this works like that

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [March 10, 2023, 9:18am UTC](https://devforum.okta.com/t/exchange-code-for-token-cors-issue/23407/12 "2023-03-10T09:18:36Z")

</div>

Closed on March 10, 2023, 9:18am UTC

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