Need help using Oauth gem for twitter

Hi All,
I have been trying to use the oauth gem with twitter. Followed the below
but i am getting “invalid or expired token”. The code below is from
twitter site itself. Maybe i am passing wrong arguments?

require ‘oauth’
require ‘yaml’

Exchange your oauth_token and oauth_token_secret for an AccessToken

instance.
def prepare_access_token(oauth_token, oauth_token_secret)
consumer = OAuth::Consumer.new(“API_key”, “API_Secret”,
{ :site => “https://api.twitter.com/1.1”,
:scheme => :header
})

now create the access token object from passed values

token_hash = { :oauth_token => oauth_token,
:oauth_token_secret => oauth_token_secret
}
access_token = OAuth::AccessToken.from_hash(consumer, token_hash)
return access_token
end

Exchange our oauth_token and oauth_token secret for the AccessToken

instance.
access_token = prepare_access_token(“consumer_key”, “consumer_secret”)

use the access token as an agent to get the home timeline

response = access_token.request(:get,
https://api.twitter.com/1.1/statuses/home_timeline.json”)
puts response.to_yaml

I have the following already provided by twitter which i am using in the
above code.
-Consumer_key
-Consumer_secret
-API_Key
-API_secret

I am printing the last line (response) to yaml to see what if i have
been authorized or not.
Help much appreciated.
Thanks