### Install Xcode Command Line Tools Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/fastlane/README.md Ensure you have the latest version of the Xcode command line tools installed before proceeding with fastlane installation. ```bash xcode-select --install ``` -------------------------------- ### Fetch Staff Picks Video List Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md An example of how to fetch a list of staff-picked videos using the Vimeo API client. It demonstrates the use of callbacks for handling success and error responses. ```kotlin val vimeoApiClient: VimeoApiClient = ... vimeoApiClient.fetchVideoList( uri = STAFF_PICKS_VIDEO_URI, fieldFilter = null, queryParams = null, cacheControl = null, callback = vimeoCallback( onSuccess = { val videoList = it.data println("Staff Picks Success!") }, onError = { println("Staff Picks Failure: ${it.message}") } ) ) ``` -------------------------------- ### Basic Data Class Example Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/model-generator/README.md This is a basic data class definition for 'Video' with a 'uri' property. ```kotlin /** * Video data */ @JsonClass(generateAdapter = true) data class Video( /** * The video's canonical relative URI. */ @Json(name = "uri") val uri: String? = null ) ``` -------------------------------- ### Install fastlane with Homebrew Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/fastlane/README.md Use Homebrew to install fastlane on macOS. This is a convenient method for macOS users. ```bash brew cask install fastlane ``` -------------------------------- ### Install fastlane with Rubygems Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/fastlane/README.md Install fastlane using Rubygems on macOS or Linux systems with Ruby 2.0.0 or above. ```bash sudo gem install fastlane -NV ``` -------------------------------- ### Get URI for Authenticated User's Videos Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Obtains the URI for fetching a list of videos owned by the authenticated user. This is the first step in retrieving a collection of the user's videos. ```kotlin val uri = "/me/videos" ``` -------------------------------- ### Get URI for a User's Videos Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Retrieves the URI for fetching videos owned by a specific user object. This requires a reference to the User object itself. ```kotlin val user = ... // Get a reference to the User object val uri = user.metadata?.connections?.videos?.uri ``` -------------------------------- ### Get Video Playback Links (DASH/HLS) Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Retrieves direct links for DASH and HLS video streams. These links are available for videos that meet specific playback requirements, such as ownership and token scope. ```kotlin val video = ... // Obtain a video you own as described above val dashLink: String? = video.play?.dash?.link val hlsLink: String? = video.play?.hls?.link // Use one of the links to play ``` -------------------------------- ### Get Video Embed HTML Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Retrieves the HTML embed code for a video. This allows the video to be displayed in an iframe, typically within a web view. ```kotlin val video = ... // Obtain a video as described in the requests section val html: String? = video.embed?.html // html is in the form "" // display the html however you wish ``` -------------------------------- ### Initialize VimeoApiClient Singleton Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Initialize the singleton instance of the VimeoApiClient. Requires VimeoApiConfiguration and the singleton Authenticator instance. ```kotlin // Initialize the singleton val vimeoApiConfiguration = ... VimeoApiClient.initialize(vimeoApiConfiguration, Authenticator.instance()) ``` -------------------------------- ### Initialize VimeoApiClient with a New Instance Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Instantiate a new VimeoApiClient object for API access. Requires VimeoApiConfiguration and an Authenticator instance. ```kotlin // Create a new instance val vimeoApiConfiguration = ... val authenticator = ... val vimeoApiClient = VimeoApiClient(vimeoApiConfiguration, authenticator) ``` -------------------------------- ### Configure SDK with Access Token Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Initialize VimeoApiConfiguration with a pre-generated access token. This is useful for apps with only one developer account and skips the need for explicit client credential or code grant requests. ```kotlin val accessToken: String = ... // Generate your access token on the API developer website val vimeoApiConfiguration = VimeoApiConfiguration.Builder(accessToken) .build() ``` -------------------------------- ### Build Vimeo API Configuration Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/auth/README.md Create an instance of VimeoApiConfiguration using your client ID, client secret, and desired scopes. This configuration is essential for authenticating with the Vimeo API. ```kotlin val configuration = VimeoApiConfiguration.Builder(CLIENT_ID, CLIENT_SECRET, listOf(ScopeType.PUBLIC, ScopeType.PRIVATE)) .build() ``` -------------------------------- ### Run Android Shipit Action Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/fastlane/README.md The main entrypoint for Continuous Integration (CI) for Android projects using fastlane. ```bash fastlane android shipit ``` -------------------------------- ### Initialize Authenticator Singleton Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Initialize the singleton instance of the Authenticator. Requires a VimeoApiConfiguration. ```kotlin // Initialize the singleton val vimeoApiConfiguration = ... Authenticator.initialize(vimeoApiConfiguration) ``` -------------------------------- ### Initialize Authenticator with a New Instance Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Instantiate a new Authenticator object for API authentication. Requires a VimeoApiConfiguration. ```kotlin // Create a new instance val vimeoApiConfiguration = ... val authenticator = Authenticator(vimeoApiConfiguration) ``` -------------------------------- ### Run Android Publish Artifacts Action Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/fastlane/README.md Publish artifacts to Bintray for Android projects using fastlane. ```bash fastlane android publish_artifacts ``` -------------------------------- ### Handle Exceptions in Vimeo SDK Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/auth/README.md This snippet demonstrates how to catch and handle general exceptions that occur during a request, such as network connection issues. It prints the underlying throwable object. ```kotlin onError = { if (it is VimeoResponse.Error.Exception) { println(it.throwable) } } ``` -------------------------------- ### Initialize Authenticator Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/auth/README.md Initialize the Authenticator with your Vimeo API configuration. You can create a new instance or use the singleton pattern for initialization. ```kotlin // (new instance) val authenticator = Authenticator(vimeoApiConfiguration) // (singleton) Authenticator.initialize(vimeoApiConfiguration) ``` -------------------------------- ### Add JitPack Repository to Gradle Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Configure your project's build.gradle file to include the JitPack repository. This is necessary for fetching the vimeo-networking library. ```groovy repositories { maven { url 'https://jitpack.io' } } ``` -------------------------------- ### Run Android Test Action Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/fastlane/README.md Execute tests for Android projects using fastlane. ```bash fastlane android test ``` -------------------------------- ### Configure Gradle for Vimeo Networking Java Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Gradle configuration to include the Vimeo Networking Java library modules in your project. ```groovy implementation project(':vimeo-networking-java:vimeo-networking') implementation project(':vimeo-networking-java:models') ``` -------------------------------- ### Apply Plugins using Plugins Block Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/model-generator/README.md Alternatively, apply the 'kotlin' and 'model.generator' plugins using a plugins block in your build.gradle file. ```groovy plugins { id 'kotlin' id 'model.generator' } ``` -------------------------------- ### Add Vimeo Networking Java as Git Submodule Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md How to add the Vimeo Networking Java library as a Git submodule to your project. ```bash git submodule add git@github.com:vimeo/vimeo-networking-java.git ``` -------------------------------- ### Fetch a List of Videos Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Requests a list of videos using a provided URI. This is used to retrieve collections of videos, such as those owned by a user. ```kotlin val uri = ... // Obtained using one of the above methods val vimeoApiClient = ... vimeoApiClient.fetchVideoList( uri = uri, fieldFilters = null, queryParams = null, cacheControl = null, callback = vimeoCallback( onSuccess = { // Getting the first video in the list. val firstVideo = it.data.data?.firstOrNull() }, onError = { // Voice the error. } ) ) ``` -------------------------------- ### Authenticate with Client Credentials Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/auth/README.md Use the Authenticator to authenticate with client credentials. A VimeoCallback is used to handle the success or error response, providing the access token or an error message. ```kotlin authenticator.authenticateWithClientCredentials(vimeoCallback( onSuccess = { println("Access Token: ${it.data.accessToken}") }, onError = { println("Couldn't obtain access token") } )) ``` -------------------------------- ### Apply Kotlin and Model Generator Plugin Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/model-generator/README.md Apply the 'kotlin' and 'model.generator' plugins in your module's build.gradle file. ```groovy apply plugin: 'kotlin' apply plugin: 'model.generator' ``` -------------------------------- ### Add Vimeo Networking Dependencies to Gradle Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Include the core vimeo-networking library and the models artifact in your app's build.gradle file. Replace LATEST-VERSION with the desired version. ```groovy implementation "com.github.vimeo.vimeo-networking-java:vimeo-networking:LATEST-VERSION" implementation "com.github.vimeo.vimeo-networking-java:models:LATEST-VERSION" ``` -------------------------------- ### Fetch a Single Video by URI Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Requests a specific video using its URI. This is useful for refreshing local video data with the latest information from Vimeo servers. ```kotlin val uri = ... // the video uri val vimeoApiClient = ... vimeoApiClient.fetchVideo( uri = uri, fieldFilter = null, queryParams = null, cacheControl = null, callback = vimeoCallback( onSuccess = { // Use the video. }, onError = { // Voice the error. } ) ) ``` -------------------------------- ### Custom Account Store for Fixed Token Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/auth/README.md Implement a custom AccountStore to hardcode a specific access token. This allows the SDK to use a predefined token for all requests without further authentication. ```kotlin class FixedTokenAccountStore(accessToken: String) : AccountStore { private val account = VimeoAccount(accessToken = accessToken) override fun loadAccount(): VimeoAccount = account override fun storeAccount(vimeoAccount: VimeoAccount) = Unit override fun removeAccount() = Unit } val vimeoApiConfiguration = VimeoApiConfiguration.Builder(CLIENT_ID, CLIENT_SECRET, listOf(ScopeType.PUBLIC)) .withAccountStore(FixedTokenAccountStore(ACCESS_TOKEN)) .build() val authenticator = Authenticator(vimeoApiConfiguration) val vimeoApiClient = VimeoApiClient(vimeoApiConfiguration, authenticator) // Any requests made will now utilize the ACCESS_TOKEN without additional log in. ``` -------------------------------- ### Apply Android Plugins using Plugins Block Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/model-generator/README.md Apply Android-related plugins and the 'model.generator' plugin using a plugins block. ```groovy plugins { id 'com.android.library' id 'kotlin-android' id 'kotlin-android-extensions' id 'model.generator' } ``` -------------------------------- ### Configure Model Generation Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/model-generator/README.md Configure the 'generated' block in your build.gradle file, specifying the input path for base models and the type of models to generate (e.g., SERIALIZABLE). ```groovy generated { // The file path for the models that you wish to // use as a base for what will be generated. inputPath = "models/src/main/java/com/vimeo/mymodels" // This desiginates what kind of models you want to generate. // For Parcelable support the module this is applied to // needs to be some sort of android module. typeGenerated = ModelType.SERIALIZABLE } ``` -------------------------------- ### Handle Unknown Errors in Vimeo SDK Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/auth/README.md This snippet is for catching rare unknown errors, which may occur if the SDK cannot parse an API response or if the API does not respond as expected. It provides access to the raw response data. ```kotlin onError = { if (error is VimeoResponse.Error.Unknown) { println(error.rawResponse) } } ``` -------------------------------- ### Apply Android and Model Generator Plugin Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/model-generator/README.md For Parcelable support, apply the 'com.android.library', 'kotlin-android', 'kotlin-android-extensions', and 'model.generator' plugins to an Android module. ```groovy apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'model.generator' ``` -------------------------------- ### Authenticate with Client Credentials Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Use the Authenticator to obtain an access token via the client credentials grant. This allows your application to access publicly accessible content on Vimeo. The VimeoApiClient is ready to make requests after successful authentication. ```kotlin val vimeoApiConfiguration: VimeoApiConfiguration = ... val authenticator: Authenticator = Authenticator(vimeoApiConfiguration) val vimeoApiClient: VimeoApiClient = VimeoApiClient(vimeoApiConfiguration, authenticator) authenticator.authenticateWithClientCredentials( vimeoCallback( onSuccess = { // Can do something with the VimeoAccount, or ignore. // It will be automatically stored in the AccountStore. // The VimeoApiClient is now ready to make requests. }, onError = { // Handle the error. } ) ) ``` -------------------------------- ### Serializable Data Class Generation Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/model-generator/README.md Generated 'Video' data class with Serializable support, including a serialVersionUID. ```kotlin /** * Video data */ @JsonClass(generateAdapter = true) data class Video( /** * The video's canonical relative URI. */ @Json(name = "uri") val uri: String? = null ) : Serializable { companion object { private const val serialVersionUID: Long = 464451044 } } ``` -------------------------------- ### Handle Invalid Token Errors in Vimeo SDK Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/auth/README.md Use this to detect and handle scenarios where the access token is invalid, possibly due to revocation or incorrect initialization. It allows access to the reason for the invalid token. ```kotlin onError = { if (it is VimeoResponse.Error.InvalidToken) { println(it.reason) } } ``` -------------------------------- ### Create Authorization URI for Code Grant Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Generates the URI needed to initiate the OAuth Authorization Code Grant flow. This URI is used to open a web browser for user authentication and authorization. ```kotlin val loginUri = createCodeGrantAuthorizationUri(requestCode = "1234567") val intent = Intent(Intent.ACTION_VIEW, Uri.parse(loginUri)) startActivity(intent) ``` -------------------------------- ### Parcelable Data Class Generation Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/model-generator/README.md Generated 'Video' data class with Parcelable support, using the @Parcelize annotation. ```kotlin /** * Video data */ @JsonClass(generateAdapter = true) @Parcelize data class Video( /** * The video's canonical relative URI. */ @Json(name = "uri") val uri: String? = null ) : Parcelable ``` -------------------------------- ### Specify Commit Hash for Dependencies via JitPack Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md If you need to use a specific commit hash instead of a release version, update the dependency declarations in your build.gradle file accordingly. ```groovy implementation "com.github.vimeo.vimeo-networking-java:vimeo-networking:COMMIT_HASH" implementation "com.github.vimeo.vimeo-networking-java:models:COMMIT_HASH" ``` -------------------------------- ### Fetch Currently Authenticated User Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Retrieves the details of the currently authenticated user. This is useful for personalizing the user experience or displaying user-specific information. ```kotlin val vimeoApiClient: VimeoApiClient = ... vimeoApiClient.fetchCurrentUser( fieldFilter = null, cacheControl = null, callback = vimeoCallback( onSuccess = { // Update the UI with information about the current user }, onError = { // Log the error and update the UI to tell the user there was an error } ) ) ``` -------------------------------- ### Handle API Errors in Vimeo SDK Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/auth/README.md Use this snippet to catch and process API-specific errors. It extracts the reason for the API error from the VimeoResponse.Error.Api object. ```kotlin onError = { if (it is VimeoResponse.Error.Api) { println(it.reason) } } ``` -------------------------------- ### AndroidManifest Intent Filter for Vimeo Auth Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/README.md Configures an Android Activity to listen for the Vimeo authorization redirect URI. This allows the application to receive the authorization code after user login. ```xml ``` -------------------------------- ### Define Scopes for API Access Source: https://github.com/vimeo/vimeo-networking-java/blob/develop/auth/README.md Define a list of ScopeType enums to specify the level of access your token will have. If no scopes are provided, ScopeType.PUBLIC is used by default. ```kotlin val scopes = listOf(ScopeType.PRIVATE, ScopeType.CREATE, ScopeType.EDIT) val vimeoApiConfiguration = VimeoApiConfiguration.Builder(CLIENT_ID, CLIENT_SECRET, scopes).build() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.