Help, Exchanging JS Token for Rest Token using Ruby Oauth

Has anyone tried exchanging the JSAPI token for Oauth token using
Oauth Gem?

I’m getting invalid signature error. Am I missing something?
The code snippets are available at following discussion link: