問題描述
Scope 在 GoogleApiClient 中的作用是什麼? (What does Scope do in GoogleApiClient?)
誰能解釋一下這個 addScope(Scope scope)
方法在 GoogleApiClient 中的作用。
new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)// what really does this?
.build();
參考解法
方法 1:
Scope defines the permissions you need to do what you need to do.
If you application needs to read from a users google drive account then you would request https://www.googleapis.com/auth/drive.readonly which grants you "read‑only access to file metadata and file content
" however if you need to be able to upload to google drive you may want to ask for https://www.googleapis.com/auth/drive which grants "Full, permissive scope to access all of a user's files."
Scope defines the scope of access an application is granted.
The scope in question Plus.login https://www.googleapis.com/auth/plus.login
This is the recommended login scope providing access to social features. This scope implicitly includes the profile scope and also requests that your app be given access to: * the age range of the authenticated user * the list of circled people that the user has granted your app access to know * the methods for reading, writing and deleting app activities (moments) to Google on behalf of the user In addition, this scope enables cross‑platform single sign‑on.
方法 2:
Scopes are strings that enable access to particular resources, such as user data.
Please see the doc and scopes summary.