LoginSignup
9
10

More than 5 years have passed since last update.

Google+ API with OAuth

Last updated at Posted at 2012-10-21

OAuthを使ってGoogle+ APIを叩く。

認証用URL

https://accounts.google.com/o/oauth2/auth?
client_id=**********.apps.googleusercontent.com&
redirect_uri=http://exsample.com/oauth2callback&
response_type=token&
approval_prompt=auto&
scope=https://www.googleapis.com/auth/plus.me

手順

  1. Google Consoleにログイン
  2. アプリケーションを登録(Webアプリケーション)
  3. Client IDを発行
  4. Redirect URLを登録

Client IDの発行とRedirect URLの指定ができたら、上記URLのようにURLを生成し、それにアクセスする。
(client_idは言わずもがな。Redirect URLに指定するのは、上記4で指定したURLを指定)
認証が通るとRedirect URLで指定されたURLにaccess_tokenなどが付与された状態で自動で遷移する。そこからaccess tokenを拾って、あとはAPIを叩くだけ。
(e.g. https://www.googleapis.com/plus/v1/people/me/activities/public?access_token=*****************)

情報を取得

Access tokenから情報を取得(IDなど)

Access tokneを使ってGoogle+ APIを叩く

[参考]

Google Accounts Authentication and Authorization

Google+ Platform - Activities: list

9
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10