live_help Notes

assignment This action requires one of theses roles: Advanced tutor, Advanced staff

settings Params

Param name Description
roles_entity optional , nil allowed . Must be a Hash
roles_entity[role_id] required . Must be Fixnum

The role id. Must be unique in the scope of a given entity id and entity type.

roles_entity[entity_id] required . Must be Fixnum

The entity id.

roles_entity[expires_at] optional , nil allowed . Must be DateTime

The expires at.

roles_entity[entity_type] required . Must be String

The entity type.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/roles_entities
{
  "roles_entity": {
    "entity_id": "8",
    "entity_type": "Doorkeeper::Application",
    "role_id": "8"
  }
}
201
{
  "id": 21,
  "entity_id": 8,
  "entity_type": "Doorkeeper::Application",
  "created_at": "2017-11-22T13:43:59.468Z",
  "expires_at": null,
  "entity": {
    "id": 8,
    "name": "test forbidden application",
    "description": null,
    "image": null,
    "website": null,
    "public": false,
    "scopes": [],
    "created_at": "2017-11-22T13:43:11.638Z",
    "updated_at": "2017-11-22T13:43:59.474Z",
    "owner": {
      "id": 116,
      "login": "mwindu2",
      "url": "https://api.intra.42.fr/v2/users/mwindu2"
    },
    "rate_limit": 1800
  },
  "role": {
    "id": 8,
    "name": "Translater",
    "description": "Ability to create and manage content translations"
  }
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"roles_entity":{"entity_id":"8","entity_type":"Doorkeeper::Application","role_id":"8"}}' "https://api.intra.42.fr/v2/roles_entities"

{
  "id": 21,
  "entity_id": 8,
  "entity_type": "Doorkeeper::Application",
  "created_at": "2017-11-22T13:43:59.468Z",
  "expires_at": null,
  "entity": {
    "id": 8,
    "name": "test forbidden application",
    "description": null,
    "image": null,
    "website": null,
    "public": false,
    "scopes": [],
    "created_at": "2017-11-22T13:43:11.638Z",
    "updated_at": "2017-11-22T13:43:59.474Z",
    "owner": {
      "id": 116,
      "login": "mwindu2",
      "url": "https://api.intra.42.fr/v2/users/mwindu2"
    },
    "rate_limit": 1800
  },
  "role": {
    "id": 8,
    "name": "Translater",
    "description": "Ability to create and manage content translations"
  }
}
require "oauth2"
UID = "Your application uid"
SECRET = "Your application secret"
client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
token = client.client_credentials.get_token

params = {roles_entity: {entity_id: "8", entity_type: "Doorkeeper::Application", role_id: "8"}}
response = token.post("/v2/roles_entities", params: params)
response.status
# => 201
response.parsed
# => {"id"=>21, "entity_id"=>8, "entity_type"=>"Doorkeeper::Application", "created_at"=>"2017-11-22T13:43:59.468Z", "expires_at"=>nil, "entity"=>{"id"=>8, "name"=>"test forbidden application", "description"=>nil, "image"=>nil, "website"=>nil, "public"=>false, "scopes"=>[], "created_at"=>"2017-11-22T13:43:11.638Z", "updated_at"=>"2017-11-22T13:43:59.474Z", "owner"=>{"id"=>116, "login"=>"mwindu2", "url"=>"https://api.intra.42.fr/v2/users/mwindu2"}, "rate_limit"=>1800}, "role"=>{"id"=>8, "name"=>"Translater", "description"=>"Ability to create and manage content translations"}}