langchainrb
langchainrb copied to clipboard
Vertex AI authentication issues
I'm having issues authenticating with Vertex with APPLICATION_DEFAULT_CREDENTIALS. I found a simple fix though.
FROM
@authorizer = ::Google::Auth.get_application_default
TO
@authorizer = ::Google::Auth.get_application_default(scope: 'https://www.googleapis.com/auth/cloud-platform')
Without fix:
VertexLLM.authorizer.fetch_access_token
(irb):1:in `<main>': Authorization failed. Server message: (Signet::AuthorizationError)
{"error":"invalid_scope","error_description":"Invalid OAuth scope or ID token audience provided."}
With fix:
VertexLLM.authorizer.fetch_access_token
=>
{"access_token"=>
"ya29xxx",
"expires_in"=>3599,
"token_type"=>"Bearer",
"granted_scopes"=>nil}
More on documentation:
- https://www.rubydoc.info/gems/googleauth/0.4.0/Google%2FAuth.get_application_default
- https://stackoverflow.com/questions/66860735/access-cloud-function-via-http-from-ruby-client-using-google-auth-gem
@palladius I think we can close this one, right?