
Untitled
By: a guest on
May 17th, 2012 | syntax:
None | size: 1.39 KB | hits: 19 | expires: Never
get client_id from foursquare by OAuth2 gem
cli = OAuth2::Client.new('CLIENT_ID', :authorize_url => "/oauth2/authorize", :token_url => "/oauth2/access_token", :site => 'https://foursquare.com')
cli = OAuth2::Client.new(client_id, client_secret, :authorize_url => "/oauth2/authorize", :token_url => "/oauth2/access_token", :site => 'https://foursquare.com')
cli.auth_code.authorize_url(:redirect_uri => "http://localhost:3000")
token = cli.auth_code.get_token('authorization_code_value', :redirect_uri => "http://localhost:3000/person/index")
response = token.get('api/resource', :params => {'query_foo' => 'bar'})
response.class.name
1. Client_id: this is a unique id assigned to your application you
create on any Oauth service provider or when you register you application.
2. Secret_key:This is another part of Oauth communication which use to
Authenticate the consumer i.e you application.
Redirect users who wish to authenticate to
https://foursquare.com/oauth2/authenticate
?client_id=YOUR_CLIENT_ID
&response_type=code
&redirect_uri=YOUR_REGISTERED_REDIRECT_URI
https://YOUR_REGISTERED_REDIRECT_URI/?code=CODE
Your server will make a request for
https://foursquare.com/oauth2/access_token
?client_id=YOUR_CLIENT_ID
&client_secret=YOUR_CLIENT_SECRET
&grant_type=authorization_code
&redirect_uri=YOUR_REGISTERED_REDIRECT_URI
&code=CODE
{ access_token: ACCESS_TOKEN }