GithubHelp home page GithubHelp logo

oAuth instructions about google_contacts_api HOT 3 CLOSED

migu0 avatar migu0 commented on July 17, 2024
oAuth instructions

from google_contacts_api.

Comments (3)

aliang avatar aliang commented on July 17, 2024

(Note, I didn't test this too much, it's from memory).

Make sure your app is set up properly, and that you've enabled the Contacts API in the Google Developers Console at https://console.developers.google.com/project. Then try this:

CLIENT_ID = '?????.apps.googleusercontent.com'
CLIENT_SECRET = 'your_secret'
REDIRECT_URI = 'url_you_registered_with_google'
client = OAuth2::Client.new(CLIENT_ID, CLIENT_SECRET, 
           site: 'https://accounts.google.com',
           token_url: '/o/oauth2/token',
           authorize_url: '/o/oauth2/auth')
url = client.auth_code.authorize_url(scope: "https://www.google.com/m8/feeds",
           redirect_uri: REDIRECT_URI)

Then visit url in your browser and log in to Google. The url you are redirected to afterwards will contain the token in the parameter code. It will look like this (not actual code to run, just an interpolation example):

redirect_url = "#{REDIRECT_URI}?code=#{code}"

Parse the code from the redirect url, then construct an API client as I describe in the docs.

token = client.auth_code.get_token(code, :redirect_uri => REDIRECT_URI)
google_contacts_user = GoogleContactsApi::User.new(token)

from google_contacts_api.

aliang avatar aliang commented on July 17, 2024

Since I haven't heard back from you I'm going to close this issue

from google_contacts_api.

migu0 avatar migu0 commented on July 17, 2024

Thanks Aliang for explaining and closing the issue. Sorry for late reply, I'm on a holiday.

from google_contacts_api.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.