# Can we use Authorization code with PKCE using Swift SDK only?

**URL:** <https://community.auth0.com/t/can-we-use-authorization-code-with-pkce-using-swift-sdk-only/183587>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, auth0-swift\
**Created:** [March 9, 2025, 5:20pm UTC](https://community.auth0.com/t/can-we-use-authorization-code-with-pkce-using-swift-sdk-only/183587 "2025-03-09T17:20:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marehoplit](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marehoplit/32/60295_2.png) [@marehoplit](https://community.auth0.com/u/marehoplit)\
**Post date:** [March 9, 2025, 5:20pm UTC](https://community.auth0.com/t/can-we-use-authorization-code-with-pkce-using-swift-sdk-only/183587/1 "2025-03-09T17:20:01Z")

</div>

I think I have read every possible document in Auth0 SDKs related to this and it seems it’s not possible.

All SDK quickstart points to using `webAuth()` which uses SSO and gives me access-token without refresh token anywhere.

I want to use access+refresh token, without having client\_secret anywhere in code. Hence authorization code flow with PKCE.  
But that does not seem possible with native SDK at all. There are no methods I see to facilitate this and online help points to implementing your own SDK with URLSessionDataTask.

Is this really the only way to do it?  
I find it strange that the least risky way of integrating 3rd party identity is not supported by the SDK at all.

---

<div class="post-metadata">

**Author:** ![vlad.murarasu](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vlad.murarasu/32/72793_2.png) [@vlad.murarasu](https://community.auth0.com/u/vlad.murarasu)\
**Post date:** [March 10, 2025, 7:26pm UTC](https://community.auth0.com/t/can-we-use-authorization-code-with-pkce-using-swift-sdk-only/183587/3 "2025-03-10T19:26:55Z")

</div>

Hi @marehoplit,

Welcome to the Auth0 Community!

The Auth0 Swift SDK uses the [Authorization Code Flow with PKCE](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-pkce#how-to-implement-it).

Native apps, must use PKCE since they cannot securely store secrets. Therefore the `.webAuth()` method inherently does this and handles the code\_challenge and code\_verifier for PKCE to work.

If you need both an access token and a refresh token, you will need to specify the `scope=offline_access` in the `webAuth()` call.

[https://auth0.github.io/Auth0.swift/documentation/auth0/webauth/#:~:text=func%20scope(String)%20-\>%20Self](https://auth0.github.io/Auth0.swift/documentation/auth0/webauth/#:~:text=func%20scope(String)%20%2D%3E%20Self)

If you have any other questions feel free to ask us.

Have a good one,  
Vlad

---

<div class="post-metadata">

**Author:** ![marehoplit](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marehoplit/32/60295_2.png) [@marehoplit](https://community.auth0.com/u/marehoplit)\
**Post date:** [March 11, 2025, 8:47am UTC](https://community.auth0.com/t/can-we-use-authorization-code-with-pkce-using-swift-sdk-only/183587/4 "2025-03-11T08:47:00Z")

</div>

Thank you, will implement this and post the results.

(`offline_access` is somewhat strange name for this scope. It suggests non-connected use which is not the case here.)

---

<div class="post-metadata">

**Author:** ![marehoplit](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/marehoplit/32/60295_2.png) [@marehoplit](https://community.auth0.com/u/marehoplit)\
**Post date:** [March 13, 2025, 4:19pm UTC](https://community.auth0.com/t/can-we-use-authorization-code-with-pkce-using-swift-sdk-only/183587/5 "2025-03-13T16:19:20Z")

</div>

This is working fine.

To any iOS dev reading this, I recommend giving a [good read to this docs](https://github.com/auth0/Auth0.swift/blob/master/EXAMPLES.md#credentials-manager-ios--macos--tvos--watchos)

---

<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 27, 2025, 4:20pm UTC](https://community.auth0.com/t/can-we-use-authorization-code-with-pkce-using-swift-sdk-only/183587/6 "2025-03-27T16:20:19Z")

</div>

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