Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fizker/swift-oauth2-models
Models for OAuth2 (RFC 6749) in Swift
https://github.com/fizker/swift-oauth2-models
oauth2 oauth2-client oauth2-server swift
Last synced: 4 days ago
JSON representation
Models for OAuth2 (RFC 6749) in Swift
- Host: GitHub
- URL: https://github.com/fizker/swift-oauth2-models
- Owner: fizker
- Created: 2020-07-13T08:38:00.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-17T13:36:43.000Z (8 months ago)
- Last Synced: 2024-04-14T18:05:32.941Z (7 months ago)
- Topics: oauth2, oauth2-client, oauth2-server, swift
- Language: Swift
- Homepage: https://fizker.github.io/swift-oauth2-models/documentation/oauth2models/
- Size: 894 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# swift-oauth2-models
Swift models compatible with the [RFC 6749 OAuth2 spec](https://tools.ietf.org/html/rfc6749).
There is no logic outside of validations for data content and parsing of the raw JSON models into Swifty types.
DocC documentation for the project can be found at [https://fizker.github.io/swift-oauth2-models/documentation/oauth2models/](https://fizker.github.io/swift-oauth2-models/documentation/oauth2models/).
## How to use
1. Add `.package(url: "https://github.com/fizker/swift-oauth2-models.git", .upToNextMinor(from: "0.3.1"))` to the list of dependencies in your Package.swift file.
2. Add `.product(name: "OAuth2Models", package: "swift-oauth2-models")` to the dependencies of the targets that need to use the models.
3. Add `import OAuth2Models` in the file and use the types. See the examples or tests for more details at this level.## Examples
For examples, see the content of the [Examples playground](Examples.playground).
- [4.5 Extension Grants](Examples.playground/Pages/4.5%20Extension%20Grant.xcplaygroundpage/Contents.swift) - Shows how to use custom types or types otherwise not supported by this library.
- [Decoding Custom Properties](Examples.playground/Pages/4.5%20Extension%20Grant.xcplaygroundpage/Contents.swift) - Shows how to decode custom properties.
Short version: Simply call `decoder.decode(type, from: data)` multiple times with different `type` values and the same `data` value.- [Encoding Custom Properties](Examples.playground/Pages/4.5%20Extension%20Grant.xcplaygroundpage/Contents.swift) - Shows how to encode custom properties.
Short version: Use a custom `Encodable` type with an array of `Encodable` items, and a custom `encode(to:)` encoding the items one after another.