Has anyone figured how how the create a user with the Admin Directory api?
I've been trying a few combinations but can't seem to come up with
something that works. I have a feeling I'm just not setting up the request
correctly. The following bit of code is known to work. I use it to set up
the client that is able to query all the users.
client = Google::APIClient.new(:application_name => "myapp", :version =>
"v0.0.0")
client.authorization = Signet::OAuth2::Client.new(
:token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
:audience => 'https://accounts.google.com/o/oauth2/token',
:scope => "https://www.googleapis.com/auth/admin.directory.user",
:issuer => issuer,
:signing_key => key,
:person => user + "@" + domain)
client.authorization.fetch_access_token!
api = client.discovered_api("admin", "directory_v1")
When I try to use the following code
parameters = Hash.new
parameters["password"] = "ThisIsAPassword"
parameters["primaryEmail"] = "tstacct2@" + domain
parameters["name"] = {"givenName" => "Test", "familyName" => "Account2"}
parameters[:api_method] = api.users.insert
response = client.execute(parameters)
I always get back the same error "code": 400, "message": "Invalid
Given/Family Name: FamilyName"
I've observed a few things while looking into this particular API. If I
print out the parameters for both the list and the insert functions e.g
puts "--- Users List ---"
puts api.users.list.parameters
puts "--- Users Insert ---"
puts api.users.insert.parameters
Only the List actually displays the parameters
--- Users List ---
customer
domain
maxResults
orderBy
pageToken
query
showDeleted
sortOrder
--- Users Insert ---
This leaves me wondering if the ruby client is unable to retrieve the api
and therefore unable to submit the request correctly or if I'm just doing
something completely wrong.
I'd appreciate any idea's or direction that might help set me on the right
path.
Thank you,
James
No comments:
Post a Comment