Data Integrations and Customization

Authorizing Data Source Requests

When integrating one of your own Web APIs with Rover experiences as a Data Source, it is often the case that you need to pass an API key along. The Rover SDK gives you a means to modify any outgoing Data Source HTTP request being issued by the Rover SDK for your API.


Call Rover.shared.authorize() and specify the hostname of your Data Source API (you can additionally glob multiple subdomains using asterisk * for wildcards), and then give a closure that receives a URLRequest value type that you can modify as needed.

For example, the following sample code for iOS and Android matches both api.example.com and stats.example.com:

iOS

Rover.shared.authorize(pattern: "*.apis.myapp.com") { urlRequest in
    urlRequest.setValue("mytoken", forHTTPHeaderField: "Authorization")
}

Android

Rover.shared.authorize("*.apis.myapp.com") { urlRequest ->
    urlRequest.headers["Authorization"] = "mytoken"
}

URLRequest on Android

On iOS we use the URLRequest type provided by the Cocoa framework, but on Android we have our own value type in a similar shape. Its task is to describe an outbound request, and offers headers and url properties that can be mutated.

Previous
AXS