List the permissions for a file by file id. (In this example the file id = 1R_70heIyzIAu1_u0prXbYcaIiJRVkgBl)
var
rest: HCkRest;
success: Boolean;
oauth2: HCkOAuth2;
sbJson: HCkStringBuilder;
json: HCkJsonObject;
kind: PWideChar;
i: Integer;
count_i: Integer;
id: PWideChar;
type: PWideChar;
role: PWideChar;
allowFileDiscovery: Boolean;
begin
rest := CkRest_Create();
// Provide a previously obtained OAuth2 access token.
oauth2 := CkOAuth2_Create();
CkOAuth2_putAccessToken(oauth2,'OAUTH2_ACCESS_TOKEN');
CkRest_SetAuthOAuth2(rest,oauth2);
success := CkRest_Connect(rest,'www.googleapis.com',443,True,True);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
CkRest_AddQueryParam(rest,'includeTeamDriveItems','true');
CkRest_AddQueryParam(rest,'supportsTeamDrives','true');
sbJson := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/drive/v3/files/1R_70heIyzIAu1_u0prXbYcaIiJRVkgBl/permissions',sbJson);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
if (CkRest_getResponseStatusCode(rest) <> 200) then
begin
Memo1.Lines.Add('Received error response code: ' + IntToStr(CkRest_getResponseStatusCode(rest)));
Memo1.Lines.Add('Response body:');
Memo1.Lines.Add(CkStringBuilder__getAsString(sbJson));
Exit;
end;
json := CkJsonObject_Create();
CkJsonObject_LoadSb(json,sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
kind := CkJsonObject__stringOf(json,'kind');
i := 0;
count_i := CkJsonObject_SizeOfArray(json,'permissions');
while i < count_i do
begin
CkJsonObject_putI(json,i);
kind := CkJsonObject__stringOf(json,'permissions[i].kind');
id := CkJsonObject__stringOf(json,'permissions[i].id');
type := CkJsonObject__stringOf(json,'permissions[i].type');
role := CkJsonObject__stringOf(json,'permissions[i].role');
allowFileDiscovery := CkJsonObject_BoolOf(json,'permissions[i].allowFileDiscovery');
i := i + 1;
end;
Memo1.Lines.Add('Example Completed.');
CkRest_Dispose(rest);
CkOAuth2_Dispose(oauth2);
CkStringBuilder_Dispose(sbJson);
CkJsonObject_Dispose(json);
{
"kind": "drive#permissionList",
"permissions": [
{
"kind": "drive#permission",
"id": "07604395918166943595k",
"type": "domain",
"role": "reader",
"allowFileDiscovery": false
},
{
"kind": "drive#permission",
"id": "05909037819814716957",
"type": "user",
"role": "organizer"
},
{
"kind": "drive#permission",
"id": "13254573739200948291",
"type": "user",
"role": "organizer"
}
]
}