Python의 Google Directory API를 통해 사용자의 맞춤 입력란을 패치/업데이트 할 수 없습니다. 나는 google-api-python-client/1.5.1을 사용하고있다.Python의 Google Directory API를 통해 사용자를위한 맞춤 필드 패치/업데이트
내 스크립트에서 생성 된 json을 사용하여 https://developers.google.com/admin-sdk/directory/v1/reference/users/patch을 통해 사용자 정의 필드를 패치/업데이트 할 수 있습니다. 내 스크립트에서 생성 된 json으로 컬을 사용하여 패치 할 수도 있습니다. 그러나 스크립트에서 직접 패치/업데이트하려고 시도하면 변경되지 않습니다. 동일한 구문으로 같은 스크립트에서 다른 필드 (모바일 번호, 유선 등)를 패치하는 데 성공 했으므로 이상합니다.
{"aswSchema":
{"adGroups":
[
{"value": "r_app_app1-ro"},
]
}
}
내가 httplib2의 디버그 로그에서 볼 :
...
OAUTH_SCOPE = 'https://www.googleapis.com/auth/admin.directory.user https://www.googleapis.com/auth/admin.directory.group'
credentials = SignedJwtAssertionCredentials(
'service-account-email',
key,
scope=OAUTH_SCOPE,
sub='[email protected]')
httplib2.debuglevel = 1
http = httplib2.Http()
http = credentials.authorize(http)
directory_service = build('admin', 'directory_v1', http=http)
params = {'customer': 'my_customer'}
...
Get user info from LDAP, returns mail, mobile and groups
...
patch = {'phones':
[
{'value': mobile, 'type': 'work_mobile', 'primary': 'true'}
]
}
try:
patchr = directory_service.users().patch(userKey=mail, body=patch).execute(http=http)
except errors.HttpError as e:
print e
customSchemas['aswSchema']['adGroups'] = []
for group in groups:
customSchemas['aswSchema']['adGroups'].append({'value': group})
patchg = json.dumps(customSchemas)
try:
patchr = directory_service.users().patch(userKey=mail, body=patchg).execute(http=http)
except errors.HttpError as e:
print e
....
patchg 변수는 다음과 같은 예를 들어입니다
send: 'PATCH /admin/directory/v1/users/user%40example.net?alt=json HTTP/1.1\r\nHost: www.googleapis.com\r\ncontent-length: 69\r\naccept-encoding: gzip, deflate\r\naccept: application/json\r\nuser-agent: google-api-python-client/1.5.1 (gzip)\r\ncontent-type: application/json\r\nauthorization: Bearer very-long-string\r\n\r\n"{\\"aswSchema\\": {\\"adGroups\\": [{\\"value\\": \\"r_net_app1-ro\\"}]}}"'
reply: 'HTTP/1.1 200 OK\r\n'
을하지만 사용자는 광고 그룹 필드가 업데이트되지 않습니다.
무엇이 문제 일 수 있습니까?
불행히도 그것은 저를 위해 작동하지 않았습니다. 또한 API 탐색기 프리폼 편집기를 통해 더 이상 업데이트 할 수 없으며 구조화 된 편집기를 사용해야합니다. 그렇지 않으면 200 코드가 수신되지만 업데이트되지 않습니다. –