### Android Setup - Add Permissions Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/README.md Adds internet and camera permissions to the AndroidManifest.xml file for Android development. ```xml ``` -------------------------------- ### Android Setup - Import SDK Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/README.md Imports the VeryOauthSDK module in Kotlin for Android development. ```kotlin import com.veryoauthsdk.* ``` -------------------------------- ### iOS Setup - Import SDK Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/README.md Imports the VeryOauthSDK module in Swift for iOS development. ```swift import VeryOauthSDK ``` -------------------------------- ### iOS Installation Workflow Source: https://context7.com/veroslabs/very-oauth-sdk/llms.txt This snippet demonstrates the steps to install the dependencies, open the workspace, and prepare the iOS project for development. ```Bash # Install dependencies cd ios pod install # Open workspace (not .xcodeproj) open MyApp.xcworkspace ``` -------------------------------- ### Install iOS CocoaPods dependencies (Bash) Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/flutter/README.md Runs CocoaPods installation to ensure native iOS dependencies are linked after adding the plugin. Execute this command from the project root after modifying iOS configuration. ```bash cd ios && pod install ``` -------------------------------- ### Perform basic OAuth authentication in Flutter (Dart) Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/flutter/README.md Demonstrates creating an OAuthConfig, invoking theOauthSDK.authenticate method, and handling success or error results. This example shows the typical flow for or verification using the SDK. ```dart import 'package:very_oauth_sdk/very_oauth_sdk.dart'; // Create OAuth configuration final config = OAuthConfig.minimal( clientId: "your_client_id", redirectUri: "your_redirect_uri", userId: "user_id", // empty string for registration, valid user_id string for verification ); // authentication try { final result = await VeryOauthSDK.authenticate(config); if (result.isSuccess) { // Send the code to your backend server print("Authentication successful: ${result.code}"); } else { print("Authentication failed: ${result.error}"); } } catch (e) { print("Error: $e"); } ``` -------------------------------- ### Android Build and Run Workflow Source: https://context7.com/veroslabs/very-oauth-sdk/llms.txt This snippet provides the commands to clean, build, install, and run the Android project after integrating the VeryOauthSDK. ```Bash # Sync Gradle and build ./gradlew clean build # Run on device/emulator ./gradlew installDebug ``` -------------------------------- ### iOS Setup - Add Camera Usage Description Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/README.md Adds a camera usage description to the Info.plist file for iOS. This is required for WebView authentication features. ```xml NSCameraUsageDescription This app needs camera access for WebView authentication features. ``` -------------------------------- ### Flutter Windows App Build and Installation in CMake Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/windows/CMakeLists.txt This CMakeLists.txt script sets up a C++17 project for a Flutter application on Windows, defining build configurations, applying standard compilation flags like /W4 /WX for MSVC, and integrating the Flutter managed directory and runner. It handles plugin bundling, native assets, and AOT libraries for non-Debug builds, with installation copying executables, data files, and assets to a bundle directory. Dependencies include CMake 3.14+ and Flutter tools; inputs are source directories; outputs are the 'flutterexample' executable and runtime bundle; limitations include Windows-specific MSVC options and no cross-platform adjustments. ```cmake # Project-level configuration. cmake_minimum_required(VERSION 3.14) project(flutterexample LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "flutterexample") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(VERSION 3.14...3.25) # Define build configuration option. get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() # Define settings for the Profile build mode. set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") # Use Unicode for all projects. add_definitions(-DUNICODE -D_UNICODE) # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() # Copy the native assets provided by the build.dart from all packages. set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE "${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### CMake Installation Rules for Application Bundle Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/linux/CMakeLists.txt Defines the installation rules for creating a relocatable application bundle. This includes cleaning the bundle directory, installing the main executable, Flutter assets, ICU data, and bundled libraries. It also handles native assets and AOT libraries based on build configuration. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install VeryOauthSDK - Android (Gradle) Source: https://context7.com/veroslabs/very-oauth-sdk/llms.txt This snippet details the installation of the VeryOauthSDK in an Android project using Gradle. It includes configuration for repositories, dependencies, and specifies the required permissions in the Android Manifest. Requires Gradle and an Android project. ```Gradle // settings.gradle pluginManagement { repositories { google() mavenCentral() gradlePluginPortal() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() // For JitPack releases (if not on Maven Central) maven { url 'https://jitpack.io' } } } ``` ```Gradle // build.gradle (Module: app) android { namespace 'com.mycompany.myapp' compileSdk 34 defaultConfig { applicationId "com.mycompany.myapp" minSdk 23 // Android 7.0 minimum targetSdk 34 versionCode 1 versionName "1.0" } buildFeatures { compose true } composeOptions { kotlinCompilerExtensionVersion '1.5.0' } kotlinOptions { jvmTarget = '1.8' } } dependencies { // VeryOauthSDK implementation 'org.very:veryoauthsdk:1.0.8' // Android core dependencies implementation 'androidx.core:core-ktx:1.12.0' implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'com.google.android.material:material:1.11.0' // Compose (optional, for UI) implementation platform('androidx.compose:compose-bom:2024.01.00') implementation 'androidx.compose.ui:ui' implementation 'androidx.compose.material3:material3' } ``` -------------------------------- ### Initialize OAuthConfig - Swift Source: https://context7.com/veroslabs/very-oauth-sdk/llms.txt Demonstrates the initialization of the OAuthConfig object in Swift. Includes examples for full configuration, quick initialization, registration, verification, and custom endpoint configurations. This config object is crucial for setting up the OAuth flow. ```swift import VeryOauthSDK // Full configuration with all optional parameters let fullConfig = OAuthConfig( clientId: "veros_145b3a8f2a8f4dc59394cbbd0dd2a77f", redirectUri: "https://myapp.example.com/oauth/callback", authorizationUrl: "https://connect.very.org/oauth/authorize", scope: "openid profile email", browserMode: .systemBrowser, // Use ASWebAuthenticationSession userId: "", // Empty string for new user registration language: "es" // Spanish UI ) // Convenience initializer for typical usage let quickConfig = OAuthConfig( clientId: "veros_145b3a8f2a8f4dc59394cbbd0dd2a77f", redirectUri: "https://myapp.example.com/oauth/callback", userId: "vu-1ed0a927-a336-45dd-9c73-20092db9ae8d" // Existing user verification ) // Registration flow - new user enrollment let registrationConfig = OAuthConfig( clientId: "veros_145b3a8f2a8f4dc59394cbbd0dd2a77f", redirectUri: "https://myapp.example.com/oauth/callback", userId: "" // Empty string triggers registration mode ) // Verification flow - authenticate existing user let verificationConfig = OAuthConfig( clientId: "veros_145b3a8f2a8f4dc59394cbbd0dd2a77f", redirectUri: "https://myapp.example.com/oauth/callback", userId: "vu-1ed0a927-a336-45dd-9c73-20092db9ae8d" // User ID from registration ) // Custom authorization endpoint (for testing/staging) let customEndpointConfig = OAuthConfig( clientId: "veros_test_client_id", redirectUri: "https://staging.myapp.example.com/oauth/callback", authorizationUrl: "https://staging.connect.very.org/oauth/authorize", scope: "openid", browserMode: .webview, userId: nil, language: "en" ) ``` -------------------------------- ### Install VeryOauthSDK - iOS (CocoaPods) Source: https://context7.com/veroslabs/very-oauth-sdk/llms.txt This snippet demonstrates how to install the VeryOauthSDK in an iOS project using CocoaPods. It outlines the steps for adding the pod to the Podfile, setting the target, and installing the dependencies. Requires CocoaPods and an iOS project. ```Ruby platform :ios, '12.0' use_frameworks! target 'MyApp' do # Install VeryOauthSDK pod 'VeryOauthSDK', '~> 1.0.8' # Other dependencies pod 'Alamofire', '~> 5.0' end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0' end end end ``` -------------------------------- ### Authenticate using VeryOauthSDK on iOS (Swift) Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/README.md Demonstrates initializing OAuthConfig with client credentials and invoking the SDK's authenticate method from a view controller. The callback reports success with a result code or prints an error description. ```Swift import VeryOauthSDK\n\nlet config = OAuthConfig(\n clientId: \"your_client_id\",\n redirectUri: \"your_redirect_uri\",\n userId: \"user_id\" // empty string for registration, valid user_id string for verification\n)\n\nVeryOauthSDK().authenticate(\n config: config,\n presentingViewController: self\n) { result in\n if result.isSuccess {\n print(\"Authentication successful: \(result.code)")\n } else {\n print(\"Authentication failed: \(result.error)\")\n }\n} ``` -------------------------------- ### CMake Project Configuration and Settings Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/linux/CMakeLists.txt This snippet sets up the basic CMake project configuration, including the minimum required version, project name, executable name, and application ID. It also enables modern CMake behaviors and sets installation paths for libraries. ```cmake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) set(BINARY_NAME "flutterexample") set(APPLICATION_ID "com.example.flutterexample") cmake_policy(SET CMP0063 NEW) set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() ``` -------------------------------- ### Authenticate using VeryOauthSDK on Android (Kotlin) Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/README.md Shows how to configure OAuthConfig and call the SDK's authenticate method in a Kotlin Android app. Handles success and maps various error types to readable messages. ```Kotlin import com.veryoauthsdk.*\n\nval config = OAuthConfig(\n clientId \"your_client_id\",\n redirectUri = \"your_redirect_uri\",\n userId = \"user_id\" // empty string for registration, valid user_id string for verification\n)\n\nVeryOauthSDK.getInstance().authenticate(\n context = context,\n config = config,\n callback = { result ->\n if (result.isSuccess) {\n println(\"Authentication successful: ${result.code}\")\n } else {\n val errorMessage = when (result.error) {\n OAuthErrorType.USER_CANCELED -> \"User cancelled authentication\"\n OAuthErrorType.VERIFICATION_FAILED -> \"Verification failed\"\n OAuthErrorType.REGISTRATION_FAILED -> \"Registration failed\"\n OAuthErrorType.TIMEOUT -> \"Request timeout\"\n OAuthErrorType.NETWORK_ERROR -> \"Network error\"\n else -> \"Unknown error occurred\"\n }\n println(\"Authentication failed: $errorMessage\")\n }\n }\n) ``` -------------------------------- ### Add VeryOauthSDK dependency for Android via Maven Central Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/README.md Provides the Gradle snippet to include VeryOauthSDK version 1.0.8 from Maven Central in an Android app module's build.gradle file. ```Gradle // build.gradle (Module: app)\ndependencies {\n implementation 'org.very:veryoauthsdk:1.0.8'\n} ``` -------------------------------- ### Initialize OAuthConfig in Flutter Source: https://context7.com/veroslabs/very-oauth-sdk/llms.txt Creates OAuth configuration objects for various authentication flows including full configuration, minimal setup, registration, verification, and WebView modes. Uses the very_oauth_sdk package for Flutter applications. ```dart import 'package:very_oauth_sdk/very_oauth_sdk.dart'; // Full configuration with all parameters final fullConfig = OAuthConfig( clientId: 'veros_145b3a8f2a8f4dc59394cbbd0dd2a77f', redirectUri: 'https://myapp.example.com/oauth/callback', userId: 'vu-1ed0a927-a336-45dd-9c73-20092db9ae8d', authorizationUrl: 'https://connect.very.org/oauth/authorize', scope: 'openid profile email', browserMode: BrowserMode.systemBrowser, language: 'ko', // Korean UI ); // Minimal configuration using convenience constructor final minimalConfig = OAuthConfig.minimal( clientId: 'veros_145b3a8f2a8f4dc59394cbbd0dd2a77f', redirectUri: 'https://myapp.example.com/oauth/callback', userId: 'vu-1ed0a927-a336-45dd-9c73-20092db9ae8d', ); // Registration flow - new user enrollment final registrationConfig = OAuthConfig.minimal( clientId: 'veros_145b3a8f4dc59394cbbd0dd2a77f', redirectUri: 'https://myapp.example.com/oauth/callback', userId: '', // Empty string triggers registration mode ); // Verification flow - authenticate existing user final verificationConfig = OAuthConfig.minimal( clientId: 'veros_145b3a8f2a8f4dc59394cbbd0dd2a77f', redirectUri: 'https://myapp.example.com/oauth/callback', userId: 'vu-1ed0a927-a336-45dd-9c73-20092db9ae8d', // User ID from registration ); // WebView mode with custom settings final webViewConfig = OAuthConfig( clientId: 'veros_145b3a8f2a8f4dc59394cbbd0dd2a77f', redirectUri: 'https://myapp.example.com/oauth/callback', userId: null, browserMode: BrowserMode.webview, scope: 'openid', language: 'fr', // French UI ); // Serialization for platform channels void demonstrateSerialization() { final config = OAuthConfig.minimal( clientId: 'client_id', redirectUri: 'https://example.com/callback', userId: 'user_123', ); // Convert to map for platform channel final map = config.toMap(); print(map); // {clientId: client_id, redirectUri: https://example.com/callback, ...} // Reconstruct from map final reconstructed = OAuthConfig.fromMap(map); assert(reconstructed.clientId == config.clientId); } ``` -------------------------------- ### POST /oauth2/token - Exchange Authorization Code for Tokens Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/flutter/README.md This endpoint is used by your backend server to exchange an authorization code obtained from the SDK for access and ID tokens. ```APIDOC ## POST /oauth2/token ### Description This endpoint exchanges an authorization code received from the Very OAuth SDK for an `access_token` and an `id_token`. This is a crucial step in the backend authentication workflow. ### Method POST ### Endpoint `https://api.very.org/oauth2/token` ### Parameters #### Query Parameters None #### Request Body - **`grant_type`** (String) - Required - Must be set to `"authorization_code"`. - **`client_id`** (String) - Required - Your application's client ID. - **`client_secret`** (String) - Required - Your application's client secret. - **`code`** (String) - Required - The authorization code obtained from the Very OAuth SDK. - **`redirect_uri`** (String) - Required - The redirect URI previously used in the initial authorization request. ### Request Example ``` POST https://api.very.org/oauth2/token Content-Type: application/x-www-form-urlencoded grant_type=authorization_code&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&code=AUTHORIZATION_CODE_FROM_SDK&redirect_uri=YOUR_REDIRECT_URI ``` ### Response #### Success Response (200) - **`access_token`** (String) - JWT used for API access. Expires in 1 hour. - **`token_type`** (String) - Type of the token, usually `"Bearer"`. - **`expires_in`** (Integer) - The duration in seconds until the `access_token` expires. - **`scope`** (String) - The scope granted for the token, e.g., `"openid"`. - **`id_token`** (String) - OIDC identity token (JWT) containing user information. #### Response Example ```json { "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "token_type": "Bearer", "expires_in": 3600, "scope": "openid", "id_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` #### Error Response (Details on error responses for this endpoint are not provided in the source text.) ``` -------------------------------- ### Add VeryOauthSDK dependency for iOS via CocoaPods and Swift Package Manager Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/README.md Shows how to declare the VeryOauthSDK dependency in an iOS project using either CocoaPods (Ruby) or Swift Package Manager (Swift). Include the appropriate snippet in your Podfile or Package.swift to fetch version 1.0.8 of the SDK. ```Ruby # Podfile\npod 'VeryOauthSDK', '~> 1.0.8' ``` ```Swift dependencies: [\n .package(url: \"https://github.com/veroslabs/very-oauth-sdk.git\", from: \"1.0.8\")\n] ``` -------------------------------- ### Add very_oauth_sdk dependency via pubspec.yaml (YAML) Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/flutter/README.md Specifies the very_oauth_sdk package source in the project's pubspec.yaml file. It pulls the SDK from the Git repository and points to the Flutter module path. This snippet is required before any SDK usage. ```yaml dependencies: very_oauth_sdk: git: url: https://github.com/veroslabs/very-oauth-sdk.git path: flutter ``` -------------------------------- ### OAuth Token Exchange Response in JSON Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/flutter/README.md This JSON snippet represents the successful response from the OAuth token endpoint after exchanging the authorization code. It includes access and ID tokens with their types, expiration, and scopes. No dependencies are required for parsing this data; input is the code from SDK. Output is structured token data for backend processing; note that the access_token expires in 1 hour. Limitations include requirement for valid client credentials and matching redirect URI. ```json { "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "token_type": "Bearer", "expires_in": 3600, "scope": "openid", "id_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` -------------------------------- ### Flask App Run Configuration - Python Source: https://context7.com/veroslabs/very-oauth-sdk/llms.txt This snippet shows how to run the Flask application. It configures the host, port, and enables SSL for development purposes using adhoc certificates. ```python if __name__ == '__main__': app.run(host='0.0.0.0', port=5000, ssl_context='adhoc') ``` -------------------------------- ### CMake Flutter and Dependency Integration Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/linux/CMakeLists.txt This snippet integrates Flutter-specific build rules and system dependencies into the CMake project. It loads bundled libraries, finds PkgConfig modules for GTK, and includes the runner subdirectory for application-specific build logic. ```cmake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_subdirectory("runner") add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### CMake Target Properties for Runtime Output Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/linux/CMakeLists.txt Configures the runtime output directory for the main binary. This ensures that the executable is placed in a specific subdirectory within the build directory, which is important for correct resource loading when the application is run directly from the build output. ```cmake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Find system dependencies with pkg-config in CMake Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/linux/flutter/CMakeLists.txt This snippet uses pkg-config to locate and import GTK, GLIB, and GIO libraries, which are required for Flutter's GTK backend on Linux. These dependencies are marked as REQUIRED. ```CMake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Configure Flutter CMake Build System Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/windows/flutter/CMakeLists.txt CMake configuration file that sets up Flutter wrapper libraries, defines build targets, and integrates Flutter tool backend for Windows development. It establishes dependency chains for plugin and app wrappers, configures include directories and libraries, and creates custom build commands for Flutter assembly. ```cmake # This file controls Flutter-level build steps. It should not be edited. cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) # === Flutter tool backend === # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Configure Flutter library in CMake Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/linux/flutter/CMakeLists.txt This section sets up the Flutter library target, including its headers, include directories, and linked libraries. It also declares dependencies on system libraries and a custom flutter_assemble target. ```CMake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### POST /oauth2/token Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/README.md This endpoint allows the backend server to exchange an authorization code, received from the Very OAuth SDK after successful palm scan authentication, for access and ID tokens. The ID token contains the user's external_user_id in the sub claim, which can be used for registration or verification. It follows the standard OAuth2 authorization code grant type. ```APIDOC ## POST /oauth2/token ### Description Exchange the authorization code for access_token and id_token after successful SDK authentication. ### Method POST ### Endpoint https://api.very.org/oauth2/token ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body Content-Type: application/x-www-form-urlencoded - **grant_type** (string) - Required - Set to 'authorization_code' - **client_id** (string) - Required - Your app’s client ID - **client_secret** (string) - Required - Your app’s client secret - **code** (string) - Required - The authorization code from the SDK - **redirect_uri** (string) - Required - The redirect URI used in the initial request ### Request Example Content-Type: application/x-www-form-urlencoded Body: grant_type=authorization_code&client_id=your_client_id&client_secret=your_client_secret&code=auth_code&redirect_uri=your_redirect_uri ### Response #### Success Response (200) - **access_token** (string) - JWT for API access (expires in 1 hour) - **token_type** (string) - Bearer - **expires_in** (integer) - Token expiration time in seconds (e.g., 3600) - **scope** (string) - Requested scopes (e.g., 'openid') - **id_token** (string) - OIDC identity token (JWT) with user info #### Response Example { "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", "token_type": "Bearer", "expires_in": 3600, "scope": "openid", "id_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." } ``` -------------------------------- ### Initialize OAuthConfig in Kotlin Source: https://context7.com/veroslabs/very-oauth-sdk/llms.txt Shows how to initialize the OAuthConfig data class in Kotlin with different configurations, including full, minimal, registration, verification and WebView modes. Supports JvmOverloads for Java interop. ```kotlin import com.veryoauthsdk.* // Full configuration with all parameters val fullConfig = OAuthConfig( clientId = "veros_145b3a8f2a8f4dc59394cbbd0dd2a77f", redirectUri = "https://myapp.example.com/oauth/callback", authorizationUrl = "https://connect.very.org/oauth/authorize", scope = "openid profile email", browserMode = BrowserMode.SYSTEM_BROWSER, // Use Chrome Custom Tabs userId = "", // Empty string for new user registration language = "ja" // Japanese UI ) // Minimal configuration with defaults val minimalConfig = OAuthConfig( clientId = "veros_145b3a8f2a8f4dc59394cbbd0dd2a77f", redirectUri = "https://myapp.example.com/oauth/callback" ) // Registration flow - new user enrollment val registrationConfig = OAuthConfig( clientId = "veros_145b3a8f2a8f4dc59394cbbd0dd2a77f", redirectUri = "https://myapp.example.com/oauth/callback", userId = "" // Empty string triggers registration mode ) // Verification flow - authenticate existing user val verificationConfig = OAuthConfig( clientId = "veros_145b3a8f2a8f4dc59394cbbd0dd2a77f", redirectUri = "https://myapp.example.com/oauth/callback", userId = "vu-1ed0a927-a336-45dd-9c73-20092db9ae8d" // User ID from registration ) // WebView mode with custom language val webViewConfig = OAuthConfig( clientId = "veros_145b3a8f2a8f4dc59394cbbd0dd2a77f", redirectUri = "https://myapp.example.com/oauth/callback", browserMode = BrowserMode.WEBVIEW, language = "zh" // Chinese UI ) // From Java code (JvmOverloads support) OAuthConfig javaConfig = new OAuthConfig( "veros_145b3a8f2a8f4dc59394cbbd0dd2a77f", "https://myapp.example.com/oauth/callback", "https://connect.very.org/oauth/authorize", "openid", BrowserMode.WEBVIEW, "vu-1ed0a927-a336-45dd-9c73-20092db9ae8d", "en" ); ``` -------------------------------- ### Decoded ID Token Structure in JSON Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/flutter/README.md This JSON snippet shows the structure of a decoded ID token (JWT) from the Very OAuth endpoint, containing user identity claims like external_user_id. Used for verifying and matching users during registration or verification. Requires JWT decoding libraries on the backend; input is the id_token string from the OAuth response. Output is verified user claims; has standard OIDC claims with expiration (exp) to check for validity. Limitations include reliance on issuer (iss) validation and potential token expiration. ```json { "iss": "https://connect.very.org", "sub": "vu-1ed0a927-a336-45dd-9c73-20092db9ae8d", "aud": ["veros_145b3a8f2a8f4dc59394cbbd0dd2a77f"], "exp": 1761013475, "nbf": 1761009875, "iat": 1761009875, "jti": "id_1761009875", "external_user_id": "vu-1ed0a927-a336-45dd-9c73-20092db9ae8d", "client_id": "veros_145b3a8f2a8f4dc59394cbbd0dd2a77f", "token_type": "id_token", "scope": "openid" } ``` -------------------------------- ### CMake Function for Standard Compilation Settings Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/linux/CMakeLists.txt Defines a CMake function `APPLY_STANDARD_SETTINGS` to apply common compilation features and options to specified targets. This function ensures consistent build configurations across different targets, particularly for C++ standards and warning levels. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "<$>:NDEBUG>") endfunction() ``` -------------------------------- ### Configure CMake build for Flutter application Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/linux/runner/CMakeLists.txt Sets up the CMake project for the Flutter runner, adding source files, applying standard settings, defining the application ID, and linking required libraries such as Flutter and GTK. No external dependencies beyond CMake 3.13 and the Flutter SDK are required. ```CMake cmake_minimum_required(VERSION 3.13) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. add_executable(${INARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add preprocessor definitions for the application ID. add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Define custom build command in CMake Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/linux/flutter/CMakeLists.txt This custom command runs the Flutter tool backend script to generate necessary build artifacts. It uses a phony output to ensure the command runs on every build. ```CMake add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Configure AndroidManifest.xml - Permissions Source: https://context7.com/veroslabs/very-oauth-sdk/llms.txt This snippet shows how to configure the AndroidManifest.xml file to declare the required permissions for the VeryOauthSDK. This includes internet and camera permissions. Requires an Android project. ```XML ``` -------------------------------- ### User Management (Find or Create) - Python Source: https://context7.com/veroslabs/very-oauth-sdk/llms.txt This function handles user data persistence. It checks if a user exists based on their external ID and either updates their last login timestamp or creates a new user record. It requires a database connection and the external user ID. ```python def find_or_create_user(external_user_id): """Find existing user or create new one""" # Query your database user = db.query('SELECT * FROM users WHERE external_user_id = ?', (external_user_id,)) if user: # Update last_login timestamp db.execute('UPDATE users SET last_login = ? WHERE id = ?', (datetime.utcnow(), user['id'])) return user else: # Create new user record user_id = db.execute( 'INSERT INTO users (external_user_id, created_at) VALUES (?, ?)', (external_user_id, datetime.utcnow()) ) return {'id': user_id, 'external_user_id': external_user_id} ``` -------------------------------- ### Define list_prepend function in CMake Source: https://github.com/veroslabs/very-oauth-sdk/blob/main/examples/flutterexample/linux/flutter/CMakeLists.txt This function prepends a prefix to each element in a list, serving as a workaround for older CMake versions that lack the list(TRANSFORM) feature. It modifies the list in the parent scope. ```CMake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ```