The OneView API lets you remotely manage the security of your endpoints. To use the API, a client credential pair is required.
Generate client credentials
To generate the credentials, log into OneView and go to Integrate.
For more information on APIs, go to the Integrate page and click on View OneView API Documentation.
Retrieve access token
An access token is required for all public API requests. For examples of obtaining an access token with JavaScript or Python, see OneView API examples in the console.
Below is an example of retrieving an access token using Ruby.
require "uri"
require "net/http"
require "json"
require "base64"
# Replace with the appropriate credentials
client_id = "your client id"
client_secret = "your client secret"
credentials = client_id + ":" + client_secret
credentialsEncoded = Base64.strict_encode64(credentials)
url = URI("https://api.malwarebytes.com/oneview/oauth2/token")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/x-www-form-urlencoded"
request["Authorization"] = "Basic " + credentialsEncoded
request.body = "grant_type=client_credentials&scope=read"
response = https.request(request)
results = JSON.parse(response.read_body)
token = results["access_token"]
puts token
url2 = URI("https://api.malwarebytes.com/oneview/v1/info/account")
request2 = Net::HTTP::Get.new(url2)
request2["Authorization"] = "Bearer " + token
response2 = https.request(request2)
results2 = JSON.parse(response2.read_body)
puts JSON.pretty_generate(results2)