An opinionated OAuthClient for authenticating to a Laravel Passport protected API.
- iOS 13+
- Swift 5
Please make a PR and once merged, a release will be tagged with the correct version number
- Client Credentials
- Password
- Refresh
Its entirely possible to use custom grant types with this package. Simply use the custom grant type and pass in the desired paramteres
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
}
}
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
}
}