-
-
Save jacquescrocker/1318784 to your computer and use it in GitHub Desktop.
google cloud print pointers
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
# this works with oauth 0.5.1 | |
client = OAuth2::Client.new(CLIENT_ID, CLIENT_SECRET, | |
:authorize_url => "/o/oauth2/auth", | |
:token_url => "/o/oauth2/token", | |
:site => 'https://accounts.google.com/') | |
redirect_uri = "#{SERVER_URL}/oauth2callback" | |
get '/auth' do | |
url = client.auth_code.authorize_url( | |
:redirect_uri => redirect_uri, | |
:scope => 'https://www.googleapis.com/auth/cloudprint', | |
:response_type => "code", | |
) | |
redirect url | |
end | |
get '/oauth2callback' do | |
access_token = client.auth_code.get_token(params[:code], :redirect_uri => redirect_uri) | |
# use curl to make a request | |
puts `curl -v -H "X-CloudPrint-Proxy: api-prober" -H "Authorization: GoogleLogin auth=#{access_token.token}" https://www.google.com/cloudprint/search` | |
# use access token helper to make a request | |
puts access_token.get("https://www.google.com/cloudprint/search") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment