aporat/APWebAuthentication
A Swift framework for in-app OAuth authentication across popular social platforms like Twitter, Reddit, Pinterest, and GitHub
β¨ Features
- π OAuth1 + OAuth2 support
- π Safari-style login UI via
WKWebView - πͺ Cookie/session handling
- π Smart retry & rate-limit UI
- π§ Customizable user-agent
- π¬ Built-in models for Reddit, Pinterest, Twitter, GitHub
π Supported Providers
- GitHub
Extendable via OAuth1Client / OAuth2Client.
π¦ Installation
Swift Package Manager
dependencies: [
.package(url: "https://github.com/aporat/APWebAuthentication.git", from: "1.0.0")
]π§βπ» Usage
let auth = Auth2Authentication()
auth.accountIdentifier = "github"
let client = GitHubAPIClient(auth: auth)
let session = APWebAuthSession(accountType: AccountStore.github) { result in
switch result {
case .success(let params):
print("Access token:", params?["access_token"] ?? "")
case .failure(let error):
print("Auth failed:", error.localizedDescription)
}
}
session.presentationContextProvider = self
session.start(url: loginURL, callbackURL: redirectURL)π Architecture
APWebAuthSessionβ UI + login flowOAuth1Client,OAuth2Clientβ Auth-aware clientsAuthClientRequestRetrierβ Retry logic & UIBaseUser,MediaItemβ Common model interfacesWebAuthViewController,WebTokenInterceptorViewControllerβ Web UI
π§ͺ Testing
Run:
swift testIncludes tests for:
- Token adapters & clients
- User & post parsing
- Rate-limit retry logic
π License
MIT
Package Metadata
Repository: aporat/APWebAuthentication
Stars: 3
Forks: 1
Open issues: 0
Default branch: main
Primary language: swift
License: MIT
README: README.md