0.0
No release in over 3 years
Low commit activity in last 3 years
OAuth strategy for OmniAuth that authenticates users with Last.fm and exposes profile metadata.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 2.1, < 3.0
 Project Readme

OmniAuth Last.fm

Test Gem Version

omniauth-lastfm is an OmniAuth strategy for authenticating with Last.fm.

Installation

Add this line to your application's Gemfile:

gem 'omniauth-lastfm'

Then run:

bundle install

Usage

Configure OmniAuth in your initializer:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :lastfm, ENV.fetch('LASTFM_API_KEY'), ENV.fetch('LASTFM_SECRET_KEY')
end

Provider App Setup

Options

  • api_timeout (default 10)
  • callback_url

Auth Hash

Example payload available in request.env['omniauth.auth'] (real flow shape, anonymized):

{
  "provider": "lastfm",
  "uid": "sample_user",
  "info": {
    "nickname": "sample_user",
    "name": "Sample User",
    "url": "https://www.last.fm/user/sample_user",
    "image": "https://lastfm.freetls.fastly.net/i/u/300x300/sample-image-id.png",
    "country": "Neverland",
    "age": "0",
    "gender": "n"
  },
  "credentials": {
    "token": "sample-session-key",
    "name": "sample_user"
  },
  "extra": {
    "raw_info": {
      "name": "sample_user",
      "age": "0",
      "subscriber": "0",
      "realname": "Sample User",
      "bootstrap": "0",
      "playcount": "49612",
      "artist_count": "399",
      "playlists": "0",
      "track_count": "5271",
      "album_count": "690",
      "image": [
        {
          "size": "small",
          "#text": "https://lastfm.freetls.fastly.net/i/u/34s/sample-image-id.png"
        },
        {
          "size": "medium",
          "#text": "https://lastfm.freetls.fastly.net/i/u/64s/sample-image-id.png"
        },
        {
          "size": "large",
          "#text": "https://lastfm.freetls.fastly.net/i/u/174s/sample-image-id.png"
        },
        {
          "size": "extralarge",
          "#text": "https://lastfm.freetls.fastly.net/i/u/300x300/sample-image-id.png"
        }
      ],
      "registered": {
        "unixtime": "1257061701",
        "#text": 1257061701
      },
      "country": "Neverland",
      "gender": "n",
      "url": "https://www.last.fm/user/sample_user",
      "type": "user"
    }
  }
}

Development

Run lint and unit tests:

bundle exec rake

Run Rails integration tests explicitly:

RAILS_VERSION='~> 7.2.0' bundle exec rake test_rails_integration

Test Structure

  • test/omniauth_lastfm_test.rb: strategy/unit behavior
  • test/rails_integration_test.rb: full Rack/Rails request+callback flow
  • test/test_helper.rb: shared test bootstrap

Compatibility

  • Ruby: 3.2, 3.3, 3.4, 4.0
  • Rails integration: 7.1, 7.2, 8.0, 8.1

Release

Tag releases as vX.Y.Z; GitHub Actions publishes the gem to RubyGems.

License

MIT