Created
July 26, 2010 19:40
-
-
Save auchenberg/491110 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def latitude | |
token = 'latisquare.kenneth.io' | |
secret = '' | |
consumer = OAuth::Consumer.new(token,secret, { | |
:site => "https://www.google.com", | |
:scheme => :header, | |
:http_method => :post, | |
:request_token_path => "/accounts/OAuthGetRequestToken", | |
:access_token_path => "/accounts/OAuthGetAccessToken", | |
:authorize_path => "/latitude/apps/OAuthAuthorizeToken", | |
:signature_method => "HMAC-SHA1" | |
}) | |
if !params[:oauth_token] | |
request_token = consumer.get_request_token({ :oauth_callback => "http://latisquare.kenneth.io:3000/auth/latitude" }, { :scope => "https://www.googleapis.com/auth/latitude" }) | |
session[:oauth_latitude_request_token] = request_token.token | |
session[:oauth_latitude_request_secret] = request_token.secret | |
redirect_to request_token.authorize_url + "&domain=latisquare.kenneth.io&granularity=best&location=all" | |
else | |
request_token = OAuth::RequestToken.new(consumer, params[:oauth_token], session[:oauth_latitude_request_secret]) | |
request_verifier = params[:oauth_verifier] | |
access_token = request_token.get_access_token(:oauth_verifier => request_verifier) | |
config = {} | |
config['access_token'] = access_token.token | |
config['access_secret'] = access_token.secret | |
File.open(Rails.root.join('db', 'latitude.yml'), 'w') {|f| f.write( YAML::dump(config)) } | |
redirect_to '/latitude' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def latitude | |
token = 'latisquare.kenneth.io' | |
secret = 'emptied' | |
consumer = OAuth::Consumer.new(token,secret, { | |
:site => "https://www.google.com", | |
:request_token_path => "/accounts/OAuthGetRequestToken", | |
:access_token_path => "/accounts/OAuthGetAccessToken", | |
:authorize_path => "/latitude/apps/OAuthAuthorizeToken", | |
:signature_method => "HMAC-SHA1" | |
}) | |
seed_file = File.join(Rails.root, 'db', 'latitude.yml') | |
config = YAML::load_file(seed_file) | |
access_token = OAuth::AccessToken.new(consumer, config['access_token'], config['access_secret']) | |
request = access_token.get("https://www.googleapis.com/latitude/v1/currentLocation").to_yaml | |
render :text => request.to_json | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment