Skip to content

Confusing error message if credentials_service_account() pointing at incorrect file #93

@MarkEdmondson1234

Description

@MarkEdmondson1234

One of the most common errors I've seen when authenticating with service accounts is that user's try to use the client JSON rather than the service account key JSON.

If I replicate this behaviour with credentials_service_account() I get an error that the file is not present, rather than it is present but the wrong file.

path <- "../../auth/client.json"
credentials_service_account(scopes = "email", path = path)
Error in read_input(file) : 
  file must be connection, raw vector or file path
> file.exists(path)
# TRUE

To help with this I check for the presence for $private_key in the JSON file, to help give a hint:

  secrets  <- fromJSON(json_file)
  
  if(is.null(secrets$private_key)){
    stop("$private_key not found in JSON - have you downloaded the correct JSON file? 
         (Service Account Keys, not service account client)")
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions