I am trying to use auth.getMobileSession method to authenticate user to my last.fm application that is built using last.fm REST api.
Last.fm says that for mobile applications we need to send AuthToken
authToken (Required) : A 32-byte ASCII hexadecimal MD5 hash of the last.fm username and the user's password hash. i.e. md5(username + md5(password)), where '+' represents a concatenation. The username supplied should match the string used to generate the authToken.
This is what I am trying to do in ruby:
password = Digest::MD5.hexdigest("my_password")
auth_token = Digest::MD5.hexdigest("#{user_name}#{password}")
url_with_params = URI.parse("#{url}?method=auth.getmobilesession&api_key=#{api_key}&username=#{user_name}&authtoken=#{auth_token}&api_sig=#{api_sig}&format=json")
resp = Net::HTTP.get_response(url_with_params)
puts JSON.parse(resp.body)
The output that I am getting is:
{"error"=>4, "message"=>"Invalid authentication token. Please check username/password supplied"}
Can anybody tell me what is it that I am doing wrong ?