goth icon indicating copy to clipboard operation
goth copied to clipboard

Impersonation docs need updating

Open cameron-bowery opened this issue 2 years ago • 2 comments

v1.3

Hi, I tried impersonating (service_account) with the two examples I could find

Tried source = {:service_account, credentials, scopes: scopes, sub: sub} as suggested here

Also tried setting the sub in the claims as suggested in the docs here

claims = %{sub: sub}
Goth.Token.fetch(source: {:service_account, credentials, [claims: claims]})                                       

but the scope and the claims can't coexist with the way the library is setup Invalid OAuth scope or ID token audience provided.

So after looking through the codebase, I realized that the claims could contain the scope. From what I can tell, this is not indicated anywhere in the docs:

claims = %{sub: sub, scope: scope}

This was the only why I was able to successfully impersonate. Unless there are any objections, I'd like to add this to both the inline docs and the README with a PR.

cameron-bowery avatar Jan 31 '23 17:01 cameron-bowery

@cameron-bowery thanks!

Wlojtek avatar Feb 16 '23 09:02 Wlojtek

v1.3

Hi, I tried impersonating (service_account) with the two examples I could find

Tried source = {:service_account, credentials, scopes: scopes, sub: sub} as suggested here

Also tried setting the sub in the claims as suggested in the docs here

claims = %{sub: sub}
Goth.Token.fetch(source: {:service_account, credentials, [claims: claims]})                                       

but the scope and the claims can't coexist with the way the library is setup Invalid OAuth scope or ID token audience provided.

So after looking through the codebase, I realized that the claims could contain the scope. From what I can tell, this is not indicated anywhere in the docs:

claims = %{sub: sub, scope: scope}

This was the only why I was able to successfully impersonate. Unless there are any objections, I'd like to add this to both the inline docs and the README with a PR.

ps. it expect claims to be a map with string keys, so use claims = %{"sub" => sub, "scope" => scope}

Wlojtek avatar Feb 16 '23 11:02 Wlojtek