OAuth 2.0 Authentication in pure Julia

I want to grab some data through an API call but I need to authenticate my requests via oauth2. What is the easiest way to do this in pure Julia?

Try the GoogleCloud package

1 Like

Sorry if I upset anyone tor reviving this thread. I’m also looking for OAuth2 support in Julia, but the reply given here seems a bit to terse for me. I could use a bit more context or perhaps even an example. I did get the package and tried to follow the tutorial linked to (here but it seems not up to date as GoogleCredentials is not available and trying to replace GoogleCredentials with JSONCredentials fails for me, complaining that function “info” is undefined.

Also, I wonder if the GoogleCloud packade is supposed to be able to provide OAuth2 support working with any api, not just Google?

Judging from the number of questions on Julia and OAuth2 I found looking I think there are more people than me still looking for some more guidance here.

3 Likes

OpenIDConnect.jl might be an alternative.

Sorry for opening, but Sonnet 3.5 also gave a wrong answer at first, so I just wanted to add as @hacklint asked for an example which is working properly.

using GoogleCloud: GoogleSession, JSONCredentials

const GOOGLE_APPLICATION_CREDENTIALS_PATH = "diabtrend-db-8213ca3be14e.json"
api_url = "https://speech.googleapis.com/v1/speech:recognize"

session = GoogleSession(
  JSONCredentials(expanduser(GOOGLE_APPLICATION_CREDENTIALS_PATH)), 
  ["https://www.googleapis.com/auth/cloud-platform"])
2 Likes