Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hendrickson-tyler/swift-pkce
A simple Swift package for the PKCE OAuth 2.0 extension
https://github.com/hendrickson-tyler/swift-pkce
codechallenge codeverifier oauth2 pkce swift
Last synced: 2 months ago
JSON representation
A simple Swift package for the PKCE OAuth 2.0 extension
- Host: GitHub
- URL: https://github.com/hendrickson-tyler/swift-pkce
- Owner: hendrickson-tyler
- License: mit
- Created: 2022-02-24T20:53:17.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-10T15:47:31.000Z (4 months ago)
- Last Synced: 2024-10-10T22:44:02.278Z (3 months ago)
- Topics: codechallenge, codeverifier, oauth2, pkce, swift
- Language: Swift
- Homepage:
- Size: 68.4 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Swift PKCE
Swift PKCE is a lightweight collection of commonly used, client-side code generations in an [OAuth 2.0 Authorization Code flow + PKCE](https://oauth.net/2/pkce/) implemented in Swift. Each function conforms to the [RFC 7636](https://datatracker.ietf.org/doc/html/rfc7636) protocol.
## Availability
Due to the dependency on [Apple CryptoKit](https://developer.apple.com/documentation/cryptokit), Swift PKCE is available to the following platforms:
iOS 13.0+\
iPadOS 13.0+\
macOS 10.15+\
Mac Catalyst 15.0+\
tvOS 15.0+\
watchOS 8.0+## Usage
Import the Swift PKCE framework by adding it to the imports at the top of the file:
```swift
import PKCE
```### Functions
**generateCodeVerifier**\
Generates a new, random code verifier with a specified length of characters.```swift
func generateCodeVerifier(length: Int = 128) throws -> String {
```**generateCodeChallenge**\
Generates a code challenge for a given code verifier.```swift
func generateCodeChallenge(for: String) throws -> String
```## Attribution
The original code for Swift PKCE was sourced from a [Bootstragram blog post](https://bootstragram.com/blog/oauth-pkce-swift-secure-code-verifiers-and-code-challenges/) written by [@dirtyhenry](https://github.com/dirtyhenry) and updated slightly.