Skip to content
Snippets Groups Projects
description.md 3.61 KiB
Newer Older
  • Learn to ignore specific revisions
  • Hugo NOUTS's avatar
    Hugo NOUTS committed
    !!! warning ""
        :construction: Section under Construction :construction:
    
    This section of documentation refers to the Enedis Oauth protocol working hand in hand with our custom proxy and the cozy-stack.
    To fully understand its whereabouts, you should also look at the [enedis konnector](./konnectors/enedis.md) documentation.
    
    !!! info "proxy code source"
        Feel free to check the proxy [code](https://forge.grandlyon.com/pocs/cozy/cozy-oauth-proxy) at all time when reading this documentation.
    
    ## Oauth Dance
    
    In order to access customer data from Ecolyo, one must first obtain customer authorization. This authorization is materialized by an access token and it must be obtained by the Authorization API exposed by Enedis.
    
    The API is implemented on Oauth 2.0 protocol, it requires authentication from the customer along with its given consent.
    
    ### Enedis Data Connect
    
    !!! info "enedis documentation"
        Create an account on https://datahub-enedis.fr/ to explore all the services exposed by Enedis.
        > [Authorize API](https://datahub-enedis.fr/data-connect/documentation/authorize-v1/) swagger
    
    Regarding Enedis, two endpoints are exposed:
    
    #### /auth
    
    <table>
      <colgroup>
        <col width="30%">
        <col width="70%">
      </colgroup>
      <thead>
        <tr class="header">
          <th>Name</th>
          <th>Description</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>client_id</td>
          <td>Unique identifier of the Application</td>
        </tr>
        <tr>
          <td>response_type</td>
          <td>Authorization scenario requested. It will always be "code" as Enedis implemented a code grant authorization</td>
        </tr>
        <tr>
          <td>state</td>
          <td>Security parameter allowing to maintain the state between the request and the redirection. ** Maximum length of 100 characters ! **</td>
        </tr>
        <tr>
          <td>duration</td>
          <td>Duration of the consent requested by the application, ISO 8601 format. It cannot exceed 3 years</td>
        </tr>
      </tbody>
    </table>
    
    !!! important "Important"
        The response targets the redirect-uri registered with Enedis (the redirect-uri is our proxy and the response will be explained in details further below when explaining the proxy endpoints mechanics).
    
    #### /token
    
    <table>
      <colgroup>
        <col width="30%">
        <col width="70%">
      </colgroup>
      <thead>
        <tr class="header">
          <th>Name</th>
          <th>Description</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>redirect_uri</td>
          <td>URI defined when the application was created. Must be secured in https</td>
        </tr>
        <tr>
          <td>content-type</td>
          <td>application/json</td>
        </tr>
        <tr>
          <td>grant_type</td>
          <td>Authorization type to get an access token. This must be set to “authorization_code” when using an authorization code, and to “refresh_token” when using a refresh token</td>
        </tr>
        <tr>
          <td>client_id</td>
          <td>Unique identifier of the Application</td>
        </tr>
        <tr>
          <td>client_secret</td>
          <td>Secret of the client application, associated with its client_id</td>
        </tr>
        <tr>
          <td>refresh_token</td>
          <td>Refresh token returned to the previous POST request to the /token endpoint</td>
        </tr>
        <tr>
          <td>code</td>
          <td>Authorization code returned to the GET request of /authorize endpoint</td>
        </tr>
      </tbody>
    </table>
    
    On success, response will contain **access_token** or **refresh_token**, **usage_point_id** among other things. All informations will be stored by the cozy-stack in a cozy-accounts database.
    
    ### Cozy Oauth Protocol
    #### Cozy Account
    ### Why we Need a Proxy
    #### Result
    
    ## Proxy Code Explained
    
    ## What Happens Next