Skip to content

Instantly share code, notes, and snippets.

@dt
Created July 28, 2012 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dt/3193621 to your computer and use it in GitHub Desktop.
Save dt/3193621 to your computer and use it in GitHub Desktop.
Play OAuth NPE
package controllers
import play.api._
import play.api.mvc._
import play.api.libs.oauth._
import play.api.libs.ws.WS
object Application extends Controller {
object MyApi {
private val ReqSigner = OAuthCalculator(
ConsumerKey("fake", "secret"), RequestToken("", ""))
def call(params: Map[String, Seq[String]] = Map.empty) = {
WS.url("http://api.example.com/v2")
.sign(ReqSigner)
.post(params)
}
}
def index = Action { Async {
MyApi.call(Map("foo" -> Seq("bar"))).map(_ => Ok("done"))
}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment