Invalid method signature supplied in radio.tune

 
  • Invalid method signature supplied in radio.tune

    So I'm fooling around with the API and have authenticated OK as explained in http://www.last.fm/api/authspec. I get my Session Key and everything is ok.

    Then when I try to post even with a simple http form to http://ws.audioscrobbler.com/2.0/ I get the following:

    <error code="13">Invalid method signature supplied</error>

    Where:
    method = radio.tune
    station = http://www.last.fm/user/alefbetac also tried lastfm://user/alefbetac/library
    api_key = my api key
    api_sig = the same one that is used for auth (and passes)
    sk= Session key resulting from auth

    What's the problem?

    Thanks in advance.

  • Solved

    I didn't realize that the api_sig had to be recreated for this and any specific method (its not clear in the documentation). Also the parameters used to generate the signature are the non- optional ones defined for that method.

    So in php that would be:

    $api_sig = "api_key". $api_key . "methodradio.tune" . "sk" . $key . "station" . $station . $secret;

    $api_sig = md5($api_sig);

    Hope someone finds this useful.

    • toc-rox said...
    • User
    • 1 Jan 2010, 21:27
    Maybe helpful - this works for me:

    Service URI ...:
    http://ws.audioscrobbler.com/2.0/
    ?api_key=099...f6c
    &api_sig=7f5...132
    &method=radio.tune
    &sk=3a5...30b
    &station=lastfm%3A%2F%2Fuser%2Falefbetac%2Flibrary

    last.fm response:
    http status ...: 200 OK

    Fill in your api_key, api_sig and sk.

  • Glad you got it sorted. How could we make the documentation clearer for this?

  • Thanks for the help, I figured it out.

    What could be improved in the documentation is the following:

    The fact that in any calls that require signing, one needs to concatenate relevant parameters that are defined for the method used.

    For example (as mentioned in the auth section):
    For a call to auth.getSession

    You should sign your calls like this:
    api_keyxxxxxxxxmethodauth.getSessiontokenxxxxxxx

    Whereas for a call to radio.tune the signing has to be expressed as follows:

    api_keyxxxxxxxxmethodradio.tuneskxxxxxxxxxxxxstationxxxxxxxxxxyyyyyyyyyyy
    where yyyyyy is my secret

    In other words one has to first check required parameters for the method used and then concatenate them in the signing.

    That wasn't clear to me but now it is :-)

    Thanks

    • toc-rox said...
    • User
    • 4 Jan 2010, 19:22
    Suggestions for an improvement of the API documentation:

    - show a complete example for a simple request (eg. method=user.getrecenttracks)
    - the example should be written in an abstract language (eg. pseudocode)

    What should be included:
    - base parameter list (eg. method=user.getrecenttracks user=toc-rox limit=10)
    - add api_key to parameter list
    - build hash string based on sorted parameter list
    - add api_secret to hash string
    - calculate md5 hash value (api_sig) for hash string
    - add calculated api_sig to parameter list
    - build URI based on sorted parameter list

    Resulting URI (example):
    http : //ws.audioscrobbler.com/2.0/
    ?api_key=099...f6c
    &api_sig=3ea...304
    &limit=10
    &method=user.getrecenttracks
    &user=toc-rox

    Further information:
    - when to use POST and when to use GET
    - some hints concerning utf-8 characters

  • Error: Invalid method signature supplied in radio.tune

    Hello,

    I am trying to tune to a radio station with the url:
    http://ws.audioscrobbler.com/2.0/?method=radio.tune&station=lastfm://artist/cher/similarartists&api_key="my api key"&api_sig="method signature"&sk="session key"

    but I am always getting response as following
    Erro code:
    <error code="13">Invalid method signature supplied</error>

    I suspect the way I created my method signature (api_sig) something is wrong here.

    I followed the link http://www.last.fm/api/authspec#8 to create the api_sig. But i always get the above error.

    Any inputs for me??
    Please share you learning on how to construct the url for radio.tune.

    Awaiting your reply.

    regards
    ~ Sreeni

  • Re: Error: Invalid method signature supplied in radio.tune

    kersken-ear said:
    I am trying to tune to a radio station with the url:
    http://ws.audioscrobbler.com/2.0/?method=radio.tune&station=lastfm://artist/cher/similarartists&api_key="my api key"&api_sig="method signature"&sk="session key"

    but I am always getting response as following
    <error code="13">Invalid method signature supplied</error>


    Why are you putting quotes around your parameters? You shouldn't do that.

    • toc-rox said...
    • User
    • 22 Jan 2010, 12:29
    Maybe helpful:

    lfm CMD - last.fm Command Line Utility (for Windows, Linux and OS X)

    Modify the source / fill in your api_key and api_secret and try the radio.tune call again. Have a lock into the log file - compare the http request and the signature calculation with yours.

    Example (utility usage):
    ~/lfmUTIL2> perl lfmCMD.pl method=radio.tune station="lastfm://user/kersken-ear/library" sk="3a5...30b"

    Fill in your session key (sk).

    Example (last.fm http request):
    http://ws.audioscrobbler.com/2.0/
    ?api_key=099...f6c
    &api_sig=e35...8a8
    &method=radio.tune
    &sk=3a5...e30b
    &station=lastfm%3A%2F%2Fuser%2Fkersken-ear%2Flibrary

  • Re: Error: Invalid method signature supplied in radio.tune

    Thank you toc-rox and thanks acreature for the quick response.

    @ toc-rox: I am not able to get any response from the link http://www.easyclasspage.de/lastfm/seite-11.html. Is there any other link available where i can get the utility?

    @ acreature: i have not used the quotes it was just used to represent the key values.

    Awaiting your kind reply.

    Regards
    ~ Sreeni

    • toc-rox said...
    • User
    • 25 Jan 2010, 10:46
    Here is an alternative link: lfmCMD

    • [Deleted user] said...
    • User
    • 9 Apr 2010, 02:21

    method not in package

    I am trying to make a call to radio.tune and am constantly returned a error code 3 - <error code="3">Invalid Method - No method with that name in this package</error>

    I am calling to the root api and am passing the params in the body like the api says. Can you see anything I am doing wrong? Here is the setup of the call:

    Sending to the below url as a post
    http://ws.audioscrobbler.com/2.0/

    in the post body is
    method=radio.tune
    station=lastfm://user/milkaxor/personal
    api_key=APIKEY
    api_sig=md5 hash of api_keyKEYmethodradio.tuneskSESSIONKEYstationlastfm://user/milkaxor/personalSECRETKEY
    sk=SESSIONKEY

    I have a session key for a user that I got from auth.getSession. I have made calls to the scrobble API for this user and those work fine. I don't think I am doing anything wrong but I may be mistaken. I have checked over and over to see if I may have made a typing mistake. I don't see any.

    Thanks

  • [spam]

    [spam]

    Edited by a deleted user on 16 Apr 2010, 23:04
  • Just for future reference, we solved this problem. The problem was the post body; we presumed that it had been formatted above for ease of debugging. Not so; the user was sending the POST body with each parameter on one line, instead of sending them all on one line and separated by ampersands. You can find more about this in this Wikipedia article.

    • eaigner said...
    • User
    • 28 Jun 2010, 12:58
    I still don't get it. My generated signature is valid when i use non-write services with GET, but as soon i try it on the writable services like radio.tune (POST) it won't accept my signature.

    I even calculated it by hand twice now and my signature is 100% correct for the post parameters.

    Here the steps in detail:

    XXX...XX == my api key
    YYY...YY == my session key
    ZZZ...ZZ == my secret

    0.) This is the original POST body of my request (without the newline of course)

    method=radio.tune&station=lastfm%3A%2Fwww.last.fm%2Flisten%2Fuser%2Feaigner%2Fpersonal
    &sk=YYYYYYYYY&lang=de&api_sig=8ac82fc2b5cba56ffd0484008b2c724e&api_key=XXXXXXXXXXXX

    1.) Now when we split this up we get

    method=radio.tune
    &station=lastfm%3A%2Fwww.last.fm%2Flisten%2Fuser%2Feaigner%2Fpersonal
    &sk=YYYYYYYYY
    &lang=de
    &api_sig=8ac82fc2b5cba56ffd0484008b2c724e
    &api_key=XXXXXXXXXX

    2.) Remove the equal signs and ampersands and the api_sig parameter (we recalculate it now, to prove correctness)

    methodradio.tune
    stationlastfm%3A%2Fwww.last.fm%2Flisten%2Fuser%2Feaigner%2Fpersonal
    skYYYYYYYYYYYYYYYYYYYY
    langde
    api_keyXXXXXXXXXXXXXX

    md5(sorted + secret) =? 8ac82fc2b5cba56ffd0484008b2c724e

    3.) Merge it into one alphabetically sorted string (without newline)

    api_keyXXXXXXXXXXlangdemethodradio.tuneskYYYYYYYYYYYYYY
    stationlastfm%3A%2Fwww.last.fm%2Flisten%2Fuser%2Feaigner%2Fpersonal

    md5(this + secret) =? 8ac82fc2b5cba56ffd0484008b2c724e

    4.) Append the secret and md5 it

    api_keyXXXXXXXXXXXXlangdemethodradio.tuneskYYYYYYYYYYYYYYYY
    stationlastfm%3A%2Fwww.last.fm%2Flisten%2Fuser%2Feaigner%2FpersonalZZZZZZZZZZZZZZZ

    md5() = 8ac82fc2b5cba56ffd0484008b2c724e

    sig = 8ac82fc2b5cba56ffd0484008b2c724e


    The signature is exactly what i would expect, but last.fm rejects it? What did go wrong here?

    • eaigner said...
    • User
    • 28 Jun 2010, 15:10
    Turns out you probably have undesired behavior in your API. I don't think escaping the station URL parameter should fail the request. if i don't percent encode the url, radio.tune accepts my method signature.

    Guys, get your API thing together :)

    • toc-rox said...
    • User
    • 28 Jun 2010, 21:33
    Maybe helpful - this works for me:

    perl lfmCMD.pl method=radio.tune station="lastfm://user/eaigner/personal" sk="3a...0b"

    <?xml version="1.0" encoding="utf-8"?>
    <lfm status="ok">
    <station>
    <type>user</type>
    <name>eaigner’s Library</name>
    <url>http://www.last.fm/listen/user/eaigner/personal</url>;
    <supportsdiscovery>1</supportsdiscovery>
    </station></lfm>

    Remark: Have a look at your station parameter.

    • arestic said...
    • User
    • 3 Jan 2011, 20:19
    I got same problem, when I try to tune the radio with url like:

    http://ws.audioscrobbler.com/2.0/?
    format=json&
    method=radio.tune&
    station=lastfm://artist/beck/similarartists&
    api_key=xxx&api_sig=yyy
    &sk=zzz

    everything is fine, but when the station url has spaces and it looks like

    station=lastfm://artist/tom%20jones/similarartists
    or
    station=lastfm://artist/tom%2520jones/similarartists
    or
    station=lastfm://artist/tom+jones/similarartists

    API throws error #13

  • [Message deleted]

  • Invalid method signature supplied

    I have to mark a track as loved
    The method i am using is track.love
    It requires 4 parameters
    Lets say,
    1) track = Back Together(title)
    2) artist = Time In Motion
    3) api_key = $(api_key)
    4) api_sig = ?
    5) sk = $(session_key)

    I am computing api_sig like this :
    api_sig = md5 operation of(api_key$(api_key)methodtrack.lovetrack$(track)artist$(artist)sk$(session_key)$(secret)

    I post the request like this :
    http://ws.audioscrobbler.com/2.0/?method=track.love&track=Back Together&artist=Time In Motion&api_key=$(api_key)&api_sig=$(api_sig)&sk=$(session_key)

    but i am getting the error as "Invalid method signature supplied"
    Could any one tell me what is wrong in computing the api_sig?

    • tburny said...
    • Forum Moderator
    • 27 Apr 2011, 22:53
    You have to sort the parameter names alphabetically first :)
    so you'd get api_key$(api_key)artist($artist)methodtrack.lovesk$(session_key)track$(track)$secret

    Combo.fm: Combine your favourite radio stations! | My Blog | scala-lastfmapi | Cache2k - A high performance Java in-memory cache
    P.S.: Do not click here
    throw new PokemonException(); //Gotta catch 'em all
    My forum post reflects my personal opinion :)
  • Invalid method signature supplied

    Thanks for the reply
    I am coding in c,Linux

    But even with the above mentioned changes i am still getting the same error. :(

    for example let me take a simple method auth.getsession

    http://ws.audioscrobbler.com/2.0/?method=auth.getsession&token=586842c5bf06f8000a5a647567138525&api_key=a3bfdecc21f431e4d8cc8ee254eccd97&api_sig=0727b05c53c5a7c0dd4f6062f7a14970


    api_sig would be
    api_sig = get_md5_hash("api_keya3bfdecc21f431e4d8cc8ee254eccd97methodauth.getsessiontoken586842c5bf06f8000a5a64756713852517e1f9de19cb6ba2b0c062dedabfcee6")


    Note:
    char *
    get_md5_hash(const char *str)
    {
    return g_compute_checksum_for_string(G_CHECKSUM_MD5, str, -1);
    }


    could you please suggest where i am going wrong?!


    Thanks
    Ramya

  • api_sig = get_md5_hash("api_keya3bfdecc21f431e4d8cc8ee254eccd97methodauth.getsessiontoken1d481b1950162f773d90834285e5f82f17e1f9de19cb6ba2b0c062dedabfcee6

    In other terms:
    md5 hash operation of (api_key$(api_key)methodauth.getsessiontoken$(token)$(secret)).

  • waiting for the reply!

    Ramya

    • tburny said...
    • Forum Moderator
    • 6 May 2011, 17:11
    hmm looks correct. the casing of parameter names is the same and everything is odered alphabetically.
    You did grant permissions via the browser before?

    Combo.fm: Combine your favourite radio stations! | My Blog | scala-lastfmapi | Cache2k - A high performance Java in-memory cache
    P.S.: Do not click here
    throw new PokemonException(); //Gotta catch 'em all
    My forum post reflects my personal opinion :)
Anonymous users may not post messages. Please log in or create an account to post in the forums.