Skip to content

User authentication

MihaiDamian edited this page Aug 1, 2011 · 2 revisions

The Last.fm API provides 3 ways to do user authentication:

  • desktop application oriented
  • web application oriented
  • mobile application oriented

Out of these options only mobile application oriented is fully handled in Lib.fm. For desktop and web authentication the library offers only partial support (read below for details).

There is no requirement to use a specific authentication path for any application type. These are only suggestions based on commonly available resources.

Desktop application authentication

Desktop application authentication is a 4 stage process:

  1. Create a token with LibFM.get_token
  2. Use LibFM.token_authorization_url to create an authorization URL
  3. Open the autorization URL in a browser; the user will use this page to grant access to your application
  4. After the user has granted access use LibFM.create_session to create a session

Web application authentication

Web application authentication is also a 4 stage process:

  1. Use LibFM.token_request_url to create an authorization URL
  2. Redirect the user to the authorization URL
  3. Receive the token either on your application's default callback or on the callback URL specified in LibFM.token_request_url (the token is provided in a GET parameter named 'token').
  4. Use LibFM.create_session to create a session

Mobile application authentication

Mobile authentication is the easiest authentication path to implement:

  1. Create a session with LibFM.create_mobile_session

The downside is that users are asked to provide their Last.fm username and password directly to your application. If possible you should use the other authentication methods.