Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated with data from latest endpoint #1

Merged
merged 1 commit into from
Oct 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/omniauth-podio/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Omniauth
module Podio
VERSION = "0.0.1"
VERSION = "0.1.0"
end
end
31 changes: 23 additions & 8 deletions lib/omniauth/strategies/podio.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,44 @@ module OmniAuth
module Strategies
class Podio < OmniAuth::Strategies::OAuth2
option :client_options, {
:site => 'https://api.podio.com/',
:authorize_url => 'https://podio.com/oauth/authorize',
:token_url => "https://podio.com/oauth/token"
site: 'https://api.podio.com/',
authorize_url: 'https://podio.com/oauth/authorize',
token_url: 'https://podio.com/oauth/token'
}

def request_phase
super
end

uid do
raw_info["user"]["user_id"]
end

info do
profile_info = raw_info["profile"]
user_info = raw_info["user"]
email = user_info["mail"]
verified = user_info["mails"].any?{|mail| mail["mail"] == email && mail["verified"] == true}

{
:email => raw_info["mail"],
:user_id => raw_info["user_id"]

email: email,
verified: verified,
name: profile_info["name"],
user_id: profile_info["user_id"].to_s,
image: profile_info["image"] && profile_info["image"]["link"],
location: profile_info["location"] && profile_info["location"][0],
status: user_info["status"],
time_zone: user_info["timezone"],
locale: user_info["locale"]
}
end

extra do
{:raw_info => raw_info}
{raw_info: raw_info}
end

def raw_info
@raw_info ||= MultiJson.decode(access_token.get('/user').body)
@raw_info ||= MultiJson.decode(access_token.get('/user/status').body)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions omniauth-podio.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ $:.push File.expand_path("../lib", __FILE__)
require "omniauth-podio/version"

Gem::Specification.new do |gem|
gem.authors = ["Lucas Allan"]
gem.email = ["lucas.allan@gmail.com"]
gem.authors = ["Lucas Allan", "Joel Van Horn"]
gem.email = ["lucas.allan@gmail.com", "joel@joelvanhorn.com"]
gem.description = %q{OmniAuth strategy for Podio.}
gem.summary = %q{OmniAuth strategy for Podio.}
gem.homepage = "https://github.com/lucasallan/omniauth-podio"
Expand Down