ボクココ

個人開発に関するテックブログ

Google+ ログインの実装の補足

基本はここを見ればできる。

https://developers.google.com/+/mobile/android/getting-started#step_4_initialize_the_plusclient

ただ、一部内容が古い所があって、そこでハマった。

PlusClient ビルダーの指定

ドキュメントではsetVisibleActivitiesてあるんだけど、このメソッドはもう存在しない。 代わりにsetActions を使い、 Google+ ログインなら setScopes(Scopes.PLUS_LOGIN)をビルダーに追加してあげる必要がある。

        PlusClient mPlusClient = new PlusClient.Builder(this, this, this)
                .setActions("http://schemas.google.com/AddActivity", "http://schemas.google.com/BuyActivity")
                .setScopes(Scopes.PLUS_LOGIN)
                .build()