Sha256: 55647a63e1997eb0462f95defc5d0eaee9c1954476a973639f419e49cf94b664
Contents?: true
Size: 1.25 KB
Versions: 8
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require File.expand_path('../../lib/discourse_api', __FILE__) config = DiscourseApi::ExampleHelper.load_yml client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000') client.api_key = config['api_key'] || "YOUR_API_KEY" client.api_username = config['api_username'] || "YOUR_USERNAME" # generate user api key response = client.create_api_key( key: { description: "Key to The Batmobile", username: "batman" } ) api_key_id = response["key"]["id"] puts response # sample output: {"key"=>{"id"=>13, "key"=>"abc", "description"=>"Key to the Batmobile"}} response = client.revoke_api_key(api_key_id) puts response # sample output: {"key"=>{"id"=>13, "key"=>"abc", "description"=>"Key to the Batmobile", "revoked_at"=>"2021-01-01T00:00:00.000Z"}} response = client.undo_revoke_api_key(api_key_id) puts response # sample output: {"key"=>{"id"=>13, "key"=>"abc", "description"=>"Key to the Batmobile", "revoked_at"=>nil}} response = client.list_api_keys puts response # sample output: {"keys"=>[{"id"=>13, "key"=>"abc", "description"=>"Key to the Batmobile"}]} response = client.delete_api_key(api_key_id) puts response # sample output: {"success"=>"OK"}
Version data entries
8 entries across 8 versions & 1 rubygems