Sha256: fc168d82c4ce5000baa895c3977909d18736efba0b49c7e3496e75cc88b8c6aa

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require 'vaas/client_credentials_grant_authenticator'
require 'vaas/resource_owner_password_grant_authenticator'
require 'vaas/vaas_main'
require 'async'


def main
    client_id = "vaas-customer"
    client_secret = ENV.fetch("CLIENT_SECRET")
    user_name = ENV.fetch("VAAS_USER_NAME")
    password = ENV.fetch("VAAS_PASSWORD")
    token_url = ENV.fetch("TOKEN_URL") || "https://account.gdata.de/realms/vaas-production/protocol/openid-connect/token"
    vaas_url = ENV.fetch("VAAS_URL") || "wss://gateway.production.vaas.gdatasecurity.de"
    test_url = "https://gdata.de"

    #If you got a username and password from us, you can use the ResourceOwnerPasswordAuthenticator like this
    authenticator = VAAS::ResourceOwnerPasswordGrantAuthenticator.new(
      client_id,
      user_name,
      password,
      token_url
    )
    # You may use self registration and create a new username and password for the
    # ResourceOwnerPasswordAuthenticator by yourself like the example above on https:#vaas.gdata.de/login

    # Else if you got a client id and client secret from us, you can use the ClientCredentialsGrantAuthenticator like this
    # authenticator = VAAS::ClientCredentialsGrantAuthenticator.new(
    #   client_id,
    #   client_secret,
    #   token_url
    # )


    vaas = VAAS::VaasMain.new(vaas_url)
    token = authenticator.get_token

    Async do
        vaas.connect(token)

        verdict = vaas.for_url(test_url)
        puts "Verdict #{verdict.wait.sha256} is detected as #{verdict.wait.verdict}"

        vaas.close
    end
end


if __FILE__  == $0
    main
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vaas-3.1.0 examples/authentication.rb