miguelperez / omniauth-uber-drivers

This is an omniauth strategy for the uber drivers API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

omniauth-uber-drivers

This is the omniauth strategy for the Uber Drivers API.

You may view the Uber Drivers API documentation.

Installation

Add to your Gemfile:

gem 'omniauth-uber-drivers'

Then bundle install.

Usage

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :uber_drivers, ENV['UBER_CLIENT_ID'], ENV['UBER_CLIENT_SECRET']
end

Do not forget setting the scope. By default it is settup to partner.accounts.

From the docs:

Scopes control the various API endpoints your application can access. When requesting an access token to use on behalf of a driver your application will specify which scopes it needs and these will be shown to the user during the OAuth flow. It’s best to limit the scopes you need to the bare minimum so that drivers can feel confident with your app and the amount of data it can access.

Available scopes: partner.accounts, partner.payments, partner.trips. Default: partner.accounts

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :uber_drivers, ENV['UBER_CLIENT_ID'], ENV['UBER_CLIENT_SECRET'], :scope => 'partner.accounts partner.payments'
end

Demo auth hash

{
  "provider"=>"uber",
  "uid"=>"xxxxx-xxxxx-xxxxxxx-xxxxxx-xxxx",
  "info"=>{
    "first_name"=>"Miguel",
    "last_name"=>"Perez",
    "email"=>"my@email.com",
    "picture"=>"profile url here",
    "promo_code"=>"something here",
    "phone_number"=> "+12345678901",
    "rating"=> 4.9,
    "activation_status"=> "active"
  },
  "credentials"=>{
    "token"=>"TOKEN COMES HERE",
    "refresh_token"=>"REFRESH HERE",
    "expires_at"=>1483271536,
    "expires"=>true
  },
  "extra"=> {
    "raw_info"=> {
      "email"=>"my@email.com",
      "first_name"=>"Miguel",
      "last_name"=>"Perez",
      "phone_number"=> "+12345678901",
      "picture"=>"profile url here",
      "promo_code"=>"something here",
      "rider_id"=>"something here too",
      "uuid"=>"xxxxx-xxxxx-xxxxxxx-xxxxxx-xxxx",
      "rating"=> 4.9,
      "activation_status"=> "active"
    }
  }
}

License

Copyright (c) 2016 by Miguel Perez

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

This is an omniauth strategy for the uber drivers API


Languages

Language:Ruby 100.0%