Calendar: Additional Scope enforced to be requested when it is not needed
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- java
- 領域
- api, authentication
調査の方向性
まず、GoogleSignInOptions requestScopes(CalendarScopes.CALENDAR_EVENTS_READONLY) のフローを UserRecoverableAuthIOException と recovery Intent まで追跡します。その動作を外部リファレンスに記載されている Calendar events.list の scope と比較します。readonly scope でイベントを一覧表示したときに、より広い calendar scope が要求されなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Environment details
- Specify the API at the beginning of the title. Calendar API
- OS type and version: Android target SDK 33
- Java version: Android 13
- version(s): com.google.apis:google-api-services-calendar:v3-rev20230707-2.0.0
Steps to reproduce
- Sign-In to Google and request Scope CALENDAR_EVENTS_READONLY =
https://www.googleapis.com/auth/calendar.events.readonly" - Retrieve the Calendar Events List for a certain CalendarID
- Get warning [GoogleAuthUtil] isUserRecoverableError status: NEED_REMOTE_CONSENT, which triggers exception UserRecoverableAuthIOException
- Upon handling exception, Request_Permission is requesting Scope "https://www.googleapis.com/auth/calendar". This is not needed, as observed in https://developers.google.com/calendar/api/v3/reference/events/list, and selecting only the events.readonly scope
Code example (simplified)
GoogleSignInOptions mGoogleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestScopes(new Scope(CalendarScopes.CALENDAR_EVENTS_READONLY)) //https://developers.google.com/identity/protocols/oauth2/scopes#calendar
.build();
// Build a GoogleSignInClient with the options specified by gso.
GoogleSignInClient mGoogleSignInClient = GoogleSignIn.getClient(MainActivity.this, mGoogleSignInOptions);
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, SIGN_IN_REQUEST_CODE);
do {
page++;
Events events;
Log.i(appLogTAG, "Sending events request, page "+page);
events = calendarService.events().list(calendarID).execute();
List<Event> items = events.getItems();
for (Event event : items) {
//some work
}
pageToken = events.getNextPageToken();
syncToken = events.getNextSyncToken();
} while (pageToken != null);
}catch (UserRecoverableAuthIOException e) {
toastInUI("Error while retrieving data. ");
//request missing permissions
Intent intent = e.getIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
appContext.startActivity(intent);
} catch (GoogleJsonResponseException e) {
if (e.getStatusCode() == 410) {
// A 410 status code, "Gone", indicates that the sync token is invalid.
Log.e(appLogTAG,"Invalid sync token, clearing event store and re-syncing.");
} else {
throw new RuntimeException(e);
}
}catch (SocketTimeoutException e) {
Log.e(appLogTAG, "Timeout while retrieving data.");
toastInUI("Timeout while retrieving data.");
}catch (IOException e) {
Log.e(appLogTAG, "Unknown error.");
throw new RuntimeException(e);
}
Stack trace
W [GoogleAuthUtil] isUserRecoverableError status: NEED_REMOTE_CONSENT
External references such as API reference guides
Any additional information below
I have tried debugging to understand where the enforced permission request comes from without success. From the link in External References the requested Scope is enough to list all events in the Calendar.
Thanks!
- 主要言語
- Java
- スター
- 725
- フォーク
- 394
- 平均マージ
- 45分
- マージ済み PR(30日)
- 240
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
googleapis/google-api-java-client-services のほかの issue
-
priority: p3 type: docs
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
-
priority: p3 type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 50/100
googleapis/google-api-java-client-services#29581 · コメント 2 件 ·
-
priority: p3 type: feature request
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
googleapis/google-api-java-client-services#29317 · コメント 1 件 ·
-
priority: p3 type: bug
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
googleapis/google-api-java-client-services#26505 · コメント 7 件 · リアクション 1 件 ·
googleapis/google-api-java-client-services の issue をすべて見る
似ている issue
-
area-deployment area-integrations triage:bot-seen
難易度 2/5 半日 初心者へのやさしさ 86/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
apache/flink-agents#1156 ·
-
[source-shopify] FAILED bulk operation without partialDataUrl is silently treated as successful オープンarea/connectors autoteam community connectors/source/shopify needs-triage team/use type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100