Repository is archived
No commit activity in last 3 years
No release in over 3 years
This gem provides the OmniAuth strategy for connecting to the Napster API.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.0

Runtime

 Project Readme

Napster Music OmniAuth Strategy

This gem provides the OmniAuth strategy for the Napster API.

Installation

Add this line to your application's Gemfile:

$ gem 'omniauth-napster'

And then execute:

$ bundle

Or install it yourself as:

$ gem install omniauth-napster

Usage

You'll need to register your app with Napster. Visit https://developer.napster.com/developer/apps/new to get started.

Using this gem is similar to other OmniAuth strategies. Add your app credentials to config/initializers/omniauth.rb:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :napster, ENV['NAPSTER_API_KEY'], ENV['NAPSTER_API_SECRET']
end

Or with Devise in config/initializers/devise.rb:

config.omniauth :napster, ENV['NAPSTER_API_KEY'], ENV['NAPSTER_API_SECRET']

Auth Hash Schema

Here's an example auth hash, available in request.env['omniauth.auth']:

{
  "provider":"napster",
  "uid":"295DC739BEDA4BB8E050960A380358BC",
  "info": {
    "uid":"295DC739BEDA4BB8E050960A380358BC",
    "name":"Testy Testerson",
    "username":"NAPIcat",
    "image":"http://direct.rhapsody.com/imageserver/v2/external/aHR0cHM6Ly9yaGFwc29keS1uYXBpLnMzLmFtYXpvbmF3cy5jb20vbWVtYmVyLzI5NURDNzM5QkVEQTRCQjhFMDUwOTYwQTM4MDM1OEJDL2F2YXRhci9vcmlnaW5hbA%3D%3D/images/108x108.jpg"
  },
  "credentials": {
    "token":"NTQ3NjI5NDktNWIyZC00MDVlLTg2MDMtZDhhMGQ2YTYzMTk3",
    "refresh_token":"0b4bdad8-1c82-44d0-8cdb-dd8d2b6e6331",
    "expires_at":1463103543,
    "expires":true
  },
  "extra": {
    "raw_info": {
      "me": {
        "id": "295DC739BEDA4BB8E050960A380358BC",
        "realName": "Testy Testerson",
        "screenName": "NAPIcat",
        "bio": "The cat is back!",
        "location":"Seattle, WA",
        "visibility": "public",
        "type": "member",
        "href": "http://api.rhapsody.com/members/295DC739BEDA4BB8E050960A380358BC",
        "favoriteAlbumsCount": 0,
        "favoriteArtistsCount": 0,
        "favoriteTracksCount": 0,
        "playlistsTotalCount": 0,
        "playlistsPublishedCount": 0,
        "stationsCount": 0,
        "radioCount": 0,
        "followingCount": 2,
        "followerCount": 10,
        "avatar": "http://direct.rhapsody.com/imageserver/v2/external/aHR0cHM6Ly9yaGFwc29keS1uYXBpLnMzLmFtYXpvbmF3cy5jb20vbWVtYmVyLzI5NURDNzM5QkVEQTRCQjhFMDUwOTYwQTM4MDM1OEJDL2F2YXRhci9vcmlnaW5hbA%3D%3D/images/108x108.jpg",
        "avatarId": "aHR0cHM6Ly9yaGFwc29keS1uYXBpLnMzLmFtYXpvbmF3cy5jb20vbWVtYmVyLzI5NURDNzM5QkVEQTRCQjhFMDUwOTYwQTM4MDM1OEJDL2F2YXRhci9vcmlnaW5hbA%3D%3D",
        "defaultAvatar": "false",
        "avatarVersion": 1465508896140
      }
    }
  }
}

More

This gem is brought to you by the NAPI (Napster API) development team. Please reach out to us if you have any questions.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request