Method: QTest::REST::API#auth
- Defined in:
- lib/qtest/rest/api.rb
#auth(opts = {}) ⇒ String
Authenticate with the QTest REST API using credentials.
If successful, an API token is returned and used on future requests.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/qtest/rest/api.rb', line 42 def auth(opts = {}) query = QueryBuilder.new .(:without_api_path) .with('/api/login') .header(:content_type, 'application/x-www-form-urlencoded') .data(j_username: opts[:username]) .data(j_password: opts[:password]) .build @token = post(query, raw: true) self.class.send(:headers, 'Authorization' => @token) @token end |