VVP
VVP

Reputation: 548

Getting the E-mail id of user in Bigquery

I am using Bigquery Java API. For authorization with Bigquery service,I am using Google OAuth 2.0.My question is :- How to get an E-mail ID of user who has granted the access on consent screen?

I am not able to find anything related to it. Is it possible to get an E-mail ID of the User. Can anyone help?
Thanks in advance :)

Upvotes: 1

Views: 1726

Answers (3)

Jeremy Condit
Jeremy Condit

Reputation: 7046

You should be able to get the user's email address as part of the OAuth flow. It looks like it's part of the JWT that you receive during this process:

https://developers.google.com/identity/protocols/OpenIDConnect#obtainuserinfo

If you're using a language-specific client library, there may be support in that client library for decoding the JWT.

Upvotes: 0

Jordan Tigani
Jordan Tigani

Reputation: 26637

In addition to Pentium10's suggestion, you can also get the user e-mail of the user who ran a particular job / query; it is in the user_email property of the job. You can see this by using bq by doing:

$ bq show --format=prettyjson -j project_id:job_id | grep user_email

Where project_id:job_id are the project and job id for the job you're looking for.

This only works to get the user e-mail if either you are a project administrator or you were the one who ran the job in the first place.

Upvotes: 0

Pentium10
Pentium10

Reputation: 208042

Just run

SELECT CURRENT_USER()

and this returns the current user's email

You can find this, and more functions in the manual: https://cloud.google.com/bigquery/query-reference

Upvotes: 2

Related Questions