MarkEdmondson1234 / googleAuthR

Google API Client Library for R. Easy authentication and help to build Google API R libraries with OAuth2. Shiny compatible.
https://code.markedmondson.me/googleAuthR
Other
175 stars 51 forks source link

Gaia id not found for email x #197

Open MarkEdmondson1234 opened 3 years ago

MarkEdmondson1234 commented 3 years ago

When using gar_service_provision() the email is not created (for example with googleAnalyticsR::gar_auth_setup() if it doesn't exist.

The check to see if the email is already there fails but does not create an email. The error message it looks for is no longer "x does not exist"

MarkEdmondson1234 commented 3 years ago

They did change the error message - this needs to be more robust, do it on a 404 not error message. Its changed from "Not found" to "Unknown service account"

In gar_service_create() :

o <- tryCatch(
    gar_service_get(candidate, projectId = projectId), 
    error = function(err){

         # watch out if they update the error message #197
         need_one <- grepl(paste("Not found"), err$message)
      ...
MarkEdmondson1234 commented 3 years ago

This is fixed now

library(googleAuthR)
projectId <- gar_set_client(Sys.getenv("GAR_CLIENT_JSON"), scopes = "https://www.googleapis.com/auth/cloud-platform")
✓ Setting client.id from /Users/mark/xxx.json

gar_auth()
The googleAuthR package is requesting access to your Google account.
Select a pre-authorised account or enter '0' to obtain a new token.
Press Esc/Ctrl + C to cancel.

1: me@work.com

Selection: 1

gar_service_create("candidate", projectId = "xxx")
ℹ 2021-11-16 16:36:16 > Request Status Code:  404
ℹ 2021-11-16 16:36:16 > Creating new service account:  candidate@xxx.iam.gserviceaccount.com
ℹ 2021-11-16 16:36:16 > Creating service accountId -  candidate
$name
[1] "projects/xxx/serviceAccounts/candidate@xxx.iam.gserviceaccount.com"

$projectId
[1] "xxx"

$uniqueId
[1] "104025210063389158565"

$email
[1] "candidate@xxx.iam.gserviceaccount.com"

$displayName
[1] "googleAuthR::gar_service_create"

$etag
[1] "MDEwMjE5MjA="

$description
[1] "A service account created via googleAuthR"

$oauth2ClientId
[1] "104025210063389158565"