https://github.com/netsells/swift-oauth-client
https://github.com/netsells/swift-oauth-client
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/netsells/swift-oauth-client
- Owner: netsells
- Created: 2021-04-29T07:26:09.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-09T15:19:50.000Z (about 3 years ago)
- Last Synced: 2025-02-02T18:52:00.296Z (3 months ago)
- Language: Swift
- Size: 27.3 KB
- Stars: 0
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OAuthClient
An opinionated OAuthClient for authenticating to a Laravel Passport protected API.
## Requirements
* iOS 13+
* Swift 5## Contributing
Please make a PR and once merged, a release will be tagged with the correct version number## Default Supported Grants
* Client Credentials
* Password
* Refresh### Custom Grant Types
Its entirely possible to use custom grant types with this package. Simply use the custom grant type and pass in the desired paramteres## Using OAuthClient
```swift
let connectionBuilder = {
OAuthServerConnection(url: URL(string: "https://test.com")!,
clientID: "1",
clientSecret: "abcdef")
}
let client = OAuthClient(connectionBuilder: connectionBuilder)client.requestToken(for: .clientCredentials) { (result) in
switch result {
case.success(let token):
// Do something
case .failure(let error):
// Handle error
}
}
``````swift
let connectionBuilder = {
OAuthServerConnection(url: URL(string: "https://test.com")!,
clientID: "1",
clientSecret: "abcdef")
}
let client = OAuthClient(connectionBuilder: connectionBuilder)client.fetchStoredToken(type: .clientCredentials) { (result) in
switch result {
case .success(let token):
// Do something with the token
case .failure(let error):
// Handle failure
}
}
```