awslabs / ssosync

Populate AWS SSO directly with your G Suite users and groups using either a CLI or AWS Lambda

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

googleapi Error 400, query invalid

jmthomas73 opened this issue · comments

After following the setup twice, including once with consultants from our managed service provider, the Lambda is giving the following error in CloudWatch:

{
"level": "fatal",
"msg": "Notifying Lambda and mark this execution as Failure: googleapi: Error 400: Invalid Input: query, invalid",
"time": "2023-09-14T21:31:27Z"
}

Steps as above. We followed directly the AWS GSuite instructions, and then the Github Readme instructions.

Expected results were for it to start populating users

We have manually created a user to validate that IAM Identity Center is functioning correctly - we can log in to our access portal URL just fine and get to the console with that manual account, but users and groups aren't populating because of the above.

Fully willing to accept this is something I've screwed up, but we've now done it twice with better trained eyes than mine watching every step, only to get the same result, so if it is me, maybe it's a documentation improvement step?

I can reproduce the issue.

I have set up SSOSync 2.0.3 via AWS CDK, using the CfnApplication construct.

When the lambda function is invoked (LogLevel = info), I see the following:
{"level":"fatal","msg":"Notifying Lambda and mark this execution as Failure: Get \"https://admin.googleapis.com/admin/directory/v1/groups?alt=json\u0026customer=my_customer\u0026prettyPrint=false\u0026query=name%!A(MISSING)AWS%!A(MISSING)\": oauth2: cannot fetch token: 400 Bad Request\nResponse: {\n \"error\": \"invalid_grant\",\n \"error_description\": \"Not a valid email or user ID.\"\n}","time":"2023-10-14T11:04:00Z"}

It looks like the API URL for Google Admin is being formatted incorrectly: instead of

  • name:AWS*

The function is sending,

  • name%!A(MISSING)AWS%!A(MISSING)

Running the latest version (latest commit is 014accf) of the CLI works fine for me.

Sorry if this is a dumb question, but is there an easy way to replace our broken 2.03 version that was deployed from the lambda application thing with the code of that commit, or alternatively, do we know when the next version that includes this will be out?

Have you tried deploying the application directly from the serverless application repository? I personally wouldn't build or deploy from the github repo, when you can pull a release version, that has been through the CICD pipeline from the SAR for far less effort.

The SAR is the only way we've done it so far, but my understanding is that the fix for my issue is in a commit that hasn't gone through that pipeline yet, correct?

I've just compared the current head on main with the v2.0.3 tag and the only changes are in the README and some ancillary scripts, changes have been made to the go.lang executable itself. Given that the release pipeline runs tests using a very similar configuration to yours, I would suspect that your are seeing a configuration issue. Can you share the values (excluding credentials or secrets) that you specified in the SAR deployment.

Thanks

I am using these CfnApplication parameters:

GoogleAdminEmail: "xxx@xxx.co.uk",
GoogleCredentials: <Google Service account credentials JSON>,
GoogleGroupMatch: "name:<My prefix>*",
IdentityStoreID: "d-xxxxxxxxxx",
LogLevel: "info",
Region: "eu-west-1",
SCIMEndpointAccessToken: <SCIM access token>,
SCIMEndpointUrl: "https://scim.eu-west-1.amazonaws.com/xxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/scim/v2/",
ScheduleExpression: "rate(1 day)",
SyncMethod: "groups",

with this applicationLocation:

applicationId: "arn:aws:serverlessrepo:us-east-2:004480582608:applications/SSOSync",
semanticVersion: "2.0.3",

For anyone who may land on this error, another possible cause is using a service account email instead of an actual google admin email. The email used for GoogleAdminEmail has to have SuperAdmin role else you can also get the above error.

I think its important to explicitly state in the docs what role the GoogleAdminEmail needs to work.