Search code examples
oauthakkaakka-http

Signing http request with Akka HTTP client for oauth1


I'm trying to find a way for executing http requests with OAuth authorization. Basically I already have all required secrets/tokens For sending such request should be signed in a rather tricky way described here: https://oauth1.wp-api.org/docs/basics/Signing.html

Are there any libraries/examples for this suitable for Akka HTTP client's API?


Solution

  • Since I didn't find any solution for that, I've implemented method for GET-requests: https://gist.github.com/Blackmorse/cdb5e13d749e7902ad47d5a168dd23ca

    Usage: E.g. you want request data from s"$URL/$API_ENDPOINT?param1=value1&param2=value2".

    To construct the Akks's akka.http.scaladsl.model.HttpRequest object:

    val request = create(Map("param1" -> "value1", "param2" -> "value2"))
    

    And use it:

    Source.single((request, someData)).via(Http().cachedHostConnectionPoolHttps[T](URL))