Google API authentication issues in Ruby

1

I'm developing an API in Ruby that communicates google-api-ruby-client but when I try to authenticate I get some errors. example of my code:

class GoogleService

    require 'googleauth'
    require 'signet/oauth_2/client' 
    require 'google/api_client/client_secrets.rb'
    require 'google/apis/plus_domains_v1'
    require 'googleauth/web_user_authorizer'
    require 'googleauth/stores/redis_token_store'
    require 'redis'

    def initialize()

        token = Google::Auth::ServiceAccountCredentials.make_creds( json_key_io: File.open('./path/meu_json.json'), scope: @scope)
        @authorization = token.fetch_access_token!
        @client_id = Google::Auth::ClientId.from_file('./path/client_secret .json')
        @token_store = Google::Auth::Stores::RedisTokenStore.new(redis: Redis.new)

    end

    def plusDomains
        @token = "TOKEN_DE_ACESSO_DO_ME_USUARIO"
        auth_client = Signet::OAuth2::Client.new(access_token: @token)

        @plus = Google::Apis::PlusDomainsV1::PlusDomainsService.new
        @plus.key = 'MINHA_CHAVE_DA_API'
        @plus.authorization = auth_client
        te = @plus.get_person(:user_id => 'me')

    end

As you can see I'm using gem Signet and google-api-ruby-client however I'm getting an error:

Sending HTTP get https://www.googleapis.com/plusDomains/v1/people/user_id,me?
Caught error Missing token endpoint URI.
Error - #<ArgumentError: Missing token endpoint URI.>

and if I by inform expires_in (this way auth_client.expires_in = Time.now + 1_000_000 ) I get this error:

Caught error forbidden: Forbidden
Error - #<Google::Apis::ClientError: forbidden: Forbidden>

I can not understand their motives because the token I get is valid. My question would be: Am I sending the information needed to authenticate user access? And if so, would that be a bug? If you are wrong you could tell me a source for research besides the official documentation because it does not make any clear of this integrations.

    
asked by anonymous 13.08.2018 / 23:37

0 answers