langchainrb icon indicating copy to clipboard operation
langchainrb copied to clipboard

Vertex AI authentication issues

Open palladius opened this issue 9 months ago • 2 comments

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')

palladius avatar May 15 '24 09:05 palladius

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}

palladius avatar May 15 '24 09:05 palladius

More on documentation:

  1. https://www.rubydoc.info/gems/googleauth/0.4.0/Google%2FAuth.get_application_default
  2. https://stackoverflow.com/questions/66860735/access-cloud-function-via-http-from-ruby-client-using-google-auth-gem

palladius avatar May 15 '24 09:05 palladius

@palladius I think we can close this one, right?

andreibondarev avatar May 21 '24 02:05 andreibondarev