I'm working on a Wolfram Language Package to connect into Google Bigquery (that I'll make public available). In order to finish It, I need to solve a last step, that is how to get an authentication token using JWT json file.
The package is working, but It's using R Script to generate the access token to be used in the Google Cloud API. Here the R code:
library(jsonlite)
library(httr)
authPath <- "/Users/rodrigomurta/Desktop/GetBigQueryToken/bigquery.json"
googleEndpoint <- httr::oauth_endpoint(
base_url = "https://accounts.google.com/o/oauth2",
authorize = "auth",
access = "token",
validate = "https://www.googleapis.com/oauth2/v1/tokeninfo",
revoke = "revoke"
)
jsonInfo <- jsonlite::fromJSON(authPath, simplifyVector = FALSE)
scope <- c(
"https://www.googleapis.com/auth/bigquery",
"https://www.googleapis.com/auth/cloud-platform"
)
token <- httr::oauth_service_token(endpoint = googleEndpoint, secrets = jsonInfo, scope = scope)
token <- token$credentials$access_token
cat(token)
The returned token is something in this format:
ya29.c.KpEB4Af1KOjCjy-msEN42XFq0IqS2DGwDG85W_Rx9WXEF_W_vGGCnG0lklw7NU25UABnWjTkwB8_NdoDsRhHHyaBLC04Cgu2mKrJ-eLQ9qlWNkwOTlpIwFCOTc-Jj1QcHzMI4JwS-nC03MeIJIC75A8bIqAEKZx90SCseNYSAKjEKw30Dbnc6Oc2k8WYwlccDlJlIQ
I tried to explore SecuredAuthenticationKey function, but without success. It would be cool to have a 100% Mathematica implementation for both facilitate distribution and make possible to run It inside Wolfram Cloud.
Some clue on how to do that?
Related: