9
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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など)

https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=****

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

https://www.googleapis.com/plus/v1/people/me?access_token=****

[参考]

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?