Aller au contenu principal

Sessions

Publié le 27 juin 2019· Mis à jour le 14 octobre 2019

Cover image for: Sessions

A session object represents access to a specific source.

Sessions are always created with a pending state, until the API is able to verify access with the target source's service.

If the target source's service revokes access, the session will transition into an expired state.

Session are not client updatable.

Attributes

nametypedescription
idstringResource identifier.
resourcestring, always sessionResource type identifier.
organisationorganisation IDThe organisation the session is associated with.
keykey IDThe key associated with this resource.
useruser IDThe user the session is associated with.
sourcenested sourceThe source instance the session is associated with.
statestringOne of: pending, active, failed, expired.
errorstringA code referring to the reason the session expired.
date_createddatetimeWhen the resource was created.
date_expireddatetimeWhen the resource expired.

States

pending : The session is still being initialised.

active : The session is ready to be used to submit tasks.

failed : Session initialisation failed.

expired : The session has been invalidated.

Errors

A session can have two types of errors: initialisation errors and expiry errors.

Session initialisation errors typically occur due to a bad username or password, the need for 2FA authentication, or the service declining access to the source for some other reason. These errors will have the init_failed error type.

Most sessions will eventually expire. More session lifetime details can be found in the service specific docs. However, there are various triggers for session expiry:

service : The third-party service has invalidated the session. This is typically due to session timeouts within the third-party service (i.e. a session can only last 24 hours). However, it can also be caused by the owner of the source changing their credentials, as this often invalidates existing session, or it can be triggered by a security feature within the service, such as an intruder detection system.

api : The API periodically invalidates inactive sessions.

organisation : The organisation has invalidated the session, possibly on behalf of the end-user.

admin : An API administrator has invalidated the session.

Create POST /sessions

Parameters

nametypedescription
sourcerequiredThe source this session will be associated to. The contents should follow the source creation schema.
payloadrequiredThe session initialisation payload. The required contents depend on the service the source belongs to.

Using cURL

curl https://ricloud-api.reincubate.com/sessions \
  -X POST \
  -H 'Authorization: Token <your key_token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "source": {
      "user": 1,
      "type": "icloud.account",
      "identifier": "john.appleseed@reincubate.com"
    },
    "payload": {
      "password": "1234"
    }
}'

Using ricloud-py

import ricloud

source = {
  'user': 1,
  'type': 'icloud.account',
  'identifier': 'john.appleseed@reincubate.com',
}

payload = {
  'password': '1234',
}

session = ricloud.Session.create(source=source, payload=payload)

Retrieve GET /sessions/{session ID}

Using cURL

curl https://ricloud-api.reincubate.com/sessions/<session ID> \
  -H 'Authorization: Token <your key_token>'

Using ricloud-py

import ricloud

session = ricloud.Session.retrieve(<session ID>)

List

GET /sessions

nametypedescription
keykey ID filterFilter by a key ID.
useruser ID filterFilter by a user ID.
sourcesource ID filterFilter by a source ID.
statestring filterFilter by the session state.
date_createddatetime filterFilter by when the session was created.
date_expireddatetime filterFilter by when the session was expired.

Using cURL

curl https://ricloud-api.reincubate.com/sessions \
  -H 'Authorization: Token <your key_token>'

Using ricloud-py

import ricloud

sessions = ricloud.Session.list()

Delete DELETE /sessions/{session ID}

This interaction expires the session and deletes any cached data associated with it on the API. The actual session resource instance is persisted for the record.

Using cURL

curl https://ricloud-api.reincubate.com/sessions/<session ID> \
  -X DELETE \
  -H 'Authorization: Token <your key_token>'

Using ricloud-py

import ricloud

session = ricloud.Session.delete_with_id(<session ID>)

# OR

session = ricloud.Session.retrieve(<session ID>)

session.delete()

Articles liés

Besoin d'aide ?

Nous nous efforçons de répondre à tous les messages sous un jour ouvré.

support@reincubate.com
Logo du King's Award for Enterprise

King's Award for Enterprise : Reincubate a remporté quatre fois la plus haute distinction officielle des entreprises du Royaume-Uni, la plus récente en reconnaissance de la croissance exceptionnelle de l'entreprise au cours des trois dernières années.

Nos relations avec les utilisateurs et les partenaires sont au cœur de nos valeurs et des produits que nous créons. Consultez nos avis pour découvrir ce qu’ils disent de nous.

Certifié ISO 27001 par le Centre for Assessment, accrédité par l'UKAS

© 2008-2026 Reincubate Ltd. Tous droits réservés. Immatriculée en Angleterre et au pays de Galles sous le n° 5189175, TVA GB151788978. Camo®, Streamlight® et Reincubate® sont des marques déposées. Brevets en instance.

Aide