Skip to content

Instantly share code, notes, and snippets.

@frnsys
Last active December 11, 2015 23:18
Show Gist options
  • Save frnsys/4675887 to your computer and use it in GitHub Desktop.
Save frnsys/4675887 to your computer and use it in GitHub Desktop.
Sessions controller for Google Reader APi
require 'oauth2'
class SessionsController < ApplicationController
def create
# Get data back from OmniAuth
@auth = request.env["omniauth.auth"]
@token = @auth["credentials"]["token"]
# Create an OAuth2 client and access token,
# which we will use to access the API.
@client = OAuth2::Client.new(AUTH_CONFIG["client_id"], AUTH_CONFIG["client_secret"], :site => "https://www.google.com/reader/")
@access_token = OAuth2::AccessToken.new(@client, @token)
# Gets the contents of the authenticated user's stream
# and prints to console
puts @access_token.get("api/0/stream/contents/").body
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment