VeryOauthSDK is a modern OAuth authentication SDK for iOS and Android applications. It provides easy-to-use APIs for OAuth 2.0 authentication with support for multiple authentication methods.
- ๐ OAuth 2.0 Authentication: Complete OAuth 2.0 flow implementation
- ๐ฑ Dual Authentication Modes:
- iOS: ASWebAuthenticationSession / WKWebView
- Android: Custom Tabs / WebView
- ๐ท Camera Support: Camera permission handling for WebView mode
- ๐จ Modern APIs: Swift and Kotlin native APIs
- ๐ Complete Documentation: API docs and usage examples
- ๐งช Example Apps: Full-featured example applications
- ๐ Cross-Platform: Consistent API across iOS and Android
- ๐ Security: Secure authentication with proper error handling
# Podfile
pod 'VeryOauthSDK', '~> 1.0.0'dependencies: [
.package(url: "https://github.com/veroslabs/very-oauth-sdk.git", from: "1.0.0")
]import VeryOauthSDK
let config = OAuthConfig(
clientId: "your_client_id",
redirectUri: "your_redirect_uri",
authorizationUrl: "https://your-auth-server.com/oauth/authorize",
scope: "openid",
authenticationMode: .systemBrowser, // or .webview
userId: "optional_user_id"
)
VeryOauthSDK.shared.authenticate(
config: config,
presentingViewController: self
) { result in
switch result {
case .success(let token, let state):
print("Authentication successful: \(token)")
case .failure(let error):
print("Authentication failed: \(error)")
case .cancelled:
print("Authentication cancelled")
}
}// build.gradle (Module: app)
dependencies {
implementation 'com.verysdk:veryoauthsdk:1.0.0'
}// build.gradle (Project)
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
// build.gradle (Module: app)
dependencies {
implementation 'com.github.your-org:very-sdk:1.0.0'
}import com.verysdk.*
val config = OAuthConfig(
clientId = "your_client_id",
redirectUri = "your_redirect_uri",
authorizationUrl = "https://your-auth-server.com/oauth/authorize",
scope = "openid",
authenticationMode = AuthenticationMode.SYSTEM_BROWSER, // or AuthenticationMode.WEBVIEW
userId = "optional_user_id"
)
VeryOauthSDK.getInstance().authenticate(
context = this,
config = config
) { result ->
when (result) {
is OAuthResult.Success -> {
println("Authentication successful: ${result.token}")
}
is OAuthResult.Failure -> {
println("Authentication failed: ${result.error}")
}
is OAuthResult.Cancelled -> {
println("Authentication cancelled")
}
}
}- iOS: Uses
ASWebAuthenticationSessionfor secure system browser authentication - Android: Uses Chrome Custom Tabs for seamless browser experience
- Benefits:
- More secure (uses system browser)
- Better user experience
- Automatic credential management
- iOS: Uses
WKWebViewfor in-app authentication - Android: Uses
WebViewfor in-app authentication - Benefits:
- Stays within your app
- Full control over UI
- Camera permission support
| Parameter | Type | Required | Description |
|---|---|---|---|
clientId |
String | โ | Your OAuth client ID |
redirectUri |
String | โ | OAuth redirect URI |
authorizationUrl |
String | โ | OAuth authorization server URL |
scope |
String | โ | OAuth scope (default: "openid") |
authenticationMode |
AuthenticationMode | โ | Authentication method |
userId |
String | โ | Optional user identifier |
| Platform | System Browser | WebView |
|---|---|---|
| iOS | .systemBrowser |
.webview |
| Android | AuthenticationMode.SYSTEM_BROWSER |
AuthenticationMode.WEBVIEW |
- iOS 12.0+
- Swift 5.0+
- Xcode 12.0+
- Android API 24+ (Android 7.0)
- Kotlin 1.8+
- Android Studio 4.0+
- Add to Info.plist
<key>NSCameraUsageDescription</key>
<string>This app needs camera access for WebView authentication features.</string>- Import and Use
import VeryOauthSDK- Add Permissions to AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />- Import and Use
import com.verysdk.*- Location:
examples/IOSExample/ - Features: SwiftUI interface, dual authentication modes
- Run: Open
IOSExample.xcodeprojin Xcode
- Location:
examples/AndroidExample/ - Features: Jetpack Compose UI, dual authentication modes
- Run:
./gradlew assembleDebug
- Secure Storage: Credentials stored securely
- HTTPS Only: All network requests use HTTPS
- State Validation: OAuth state parameter validation
- Error Handling: Comprehensive error handling
- Permission Management: Proper camera permission handling
class VeryOauthSDK {
static let shared: VeryOauthSDK
func authenticate(
config: OAuthConfig,
presentingViewController: UIViewController,
callback: @escaping (OAuthResult) -> Void
)
func cancelAuthentication()
}class OAuthConfig {
let clientId: String
let redirectUri: String
let authorizationUrl: String
let scope: String?
let authenticationMode: AuthenticationMode
let userId: String?
}class OAuthResult {
class Success: OAuthResult {
let token: String
let state: String?
}
class Failure: OAuthResult {
let error: Error
}
class Cancelled: OAuthResult
}class VeryOauthSDK {
companion object {
fun getInstance(): VeryOauthSDK
}
fun authenticate(
context: Context,
config: OAuthConfig,
callback: (OAuthResult) -> Unit
)
}class OAuthConfig(
val clientId: String,
val redirectUri: String,
val authorizationUrl: String,
val scope: String? = null,
val authenticationMode: AuthenticationMode = AuthenticationMode.SYSTEM_BROWSER,
val userId: String? = null
)sealed class OAuthResult {
data class Success(val token: String, val state: String?) : OAuthResult()
data class Failure(val error: Throwable) : OAuthResult()
object Cancelled : OAuthResult()
}- Camera Permission: Ensure
NSCameraUsageDescriptionis added to Info.plist - URL Scheme: Verify redirect URI matches your app's URL scheme
- iOS Version: Requires iOS 12.0+ for ASWebAuthenticationSession
- Permissions: Add INTERNET and CAMERA permissions to AndroidManifest.xml
- Theme: Ensure AppCompat theme is used for OAuthActivity
- ProGuard: Add rules to prevent obfuscation of SDK classes
// iOS
switch result {
case .failure(let error):
if let oauthError = error as? OAuthError {
switch oauthError {
case .invalidRedirectUri:
// Handle invalid redirect URI
case .authenticationFailed:
// Handle authentication failure
case .userCancelled:
// Handle user cancellation
case .networkError(let error):
// Handle network error
}
}
}// Android
when (result) {
is OAuthResult.Failure -> {
when (result.error) {
is OAuthError.InvalidRedirectUri -> {
// Handle invalid redirect URI
}
is OAuthError.AuthenticationFailed -> {
// Handle authentication failure
}
is OAuthError.UserCancelled -> {
// Handle user cancellation
}
is OAuthError.NetworkError -> {
// Handle network error
}
}
}
}- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: https://very-sdk-docs.vercel.app
- Issues: GitHub Issues
- Email: [email protected]
- Initial release
- iOS and Android support
- Dual authentication modes
- Camera permission support
- Complete OAuth 2.0 implementation
VeryOauthSDK - Making OAuth authentication simple and secure across platforms.