Estrarre un token API di aws da poter poi utilizzare su appscript

MRPants

Helper
4 Gennaio 2015
289
34
259
269
Buonasera inforgiani ,

Sto lavorando su un progetto che richiede l'integrazione tra un'applicazione basata su AppScript e l'API della webapp di AWS. Nel documento OpenAPI, ho trovato alcunei informazioni sul processo di autenticazione e ottenimento di un Bearer Token.

Mi servirebbero delle dritte su come effettuare questa operazione in modo specifico e come integrare il token che poi andraò ad utilizzare su uno script in AppScript.

Le informazioni nel documento OpenAPI indicano che è possibile ottenere il Bearer Token utilizzando l'AWS SDK for Cognito, ma mi piacerebbe avere ulteriori dettagli su come configurare questo processo. In particolare, sono interessato a:

- configurare il client Cognito utilizzando i parametri forniti nel documento, come clientId, redirect_uri, userPoolId, region, username e password.
- i passaggi esatti per ottenere il "Bearer Token" tramite il client Cognito.
- Come utilizzare il "Bearer Token" ottenuto con successo nell'applicazione AppScript per effettuare richieste all'API dalla webapp.

Non vi stò chiedendo di farmi il lavoro , mi interesserebbe qualche dritta o consiglio su come poter risolvere senza soluzioni troppo macchinose

Qui a seguire le istruzioni sulla webApp fornitemi :

Codice:
openapi: '3.0.2'
info:
    title: 'webApp1'
    version: '1.0'
   
    contact:
      name: API Support
      email: [email protected]
   
    description: |

      # Introduction
 
      Programmatic access to WebApp1 referential (Site/Asset/Device/Variables) and historical data (timeseries).
 
      # Technical details
 
      ## Client guidance
 
      (from [Microsoft API Guidelines](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md))
 
      To ensure the best possible experience for clients talking to a REST service, clients SHOULD adhere to the following best practices:
 
 
      ### Ignore rule
 
      For loosely coupled clients where the exact shape of the data is not known before the call, if the server returns something the client wasn't expecting, the client MUST safely ignore it.

 
      ### Variable order rule
 
      Clients MUST NOT rely on the order in which data appears in JSON service responses.
      For example, clients SHOULD be resilient to the reordering of fields within a JSON object.
 
 
      ## Authentication
     
      Authentication relies on the combined usage of headers and Bearer token Authorization.
 
      ### Request headers :
     
      * `apikey` :  Request header of the API key to authenticate to Synapse
      * `Authorization` : Request header to authenticate via a Bearer token
      * `business-profile-id` : Request header for the technical ID of the business profile (profile with a defined set of rights) used by your server
     
      <u><i>How to get your API key</i></u>
     
      API Key value can be retrieved by following the given process :
     
      * Login to WebApp1 on the account that will be used by your application
      * Go to "MY PROFILE" by clicking on the account icon on the top right corner of the WebApp1 page
      * Click on "+" on the section called "API keys" in order to generate a new API key. /!\ Limit of <b>2</b> keys per account
      * Copy your API key value by clicking first on the "eye" icon next to your key ID then clicking on the "COPY" button of your popup
     
      <i>Each key can be revoked by clicking on the garbage button next to your key then validating your action with the confirmation popup.</i>
     
      <u><i>How to get an Authorization bearer token</i></u>
     
      Authorization bearer token can be retrieved by using the [AWS SDK for Cognito](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-cognito-identity-provider/).
      Authentication parameters :
      * `clientId : WebApp1veb1xb27sl6y7ubb`
      * `redirect_uri : https://bos.iot.WebApp1.com/login/callback`
      * `userPoolId : eu-west-1_XxDESKMzE`
      * `region : eu-west-1`
      * `username : your_WebApp1_username`
      * `password : your_WebApp1_password`
     
      <u><i>How to get your business profile technical ID</i></u>
     
      API Key value can be retrieved by following the given process :
      * Login to WebApp1 on the account that will be used by your application
      * Open your brower dev console pressing "FN + F12" or "F12" depending on your laptop
      * Select the "Network" section of the dev console
      * Go to "Business profiles in the "Administration" menu
      * Retrieve the "id" field of the desired business profile in the response of the API call using the GET /business-profiles
     

      # Miscellaneous notes
 
      ## Case `http/500`
 
      You SHOULD never get any `http/500` errors. However, it may happen (WAF restriction, backend server crash, etc.).
 
      In case of WAF issue, you will find the `SupportID` required to check with support team into reponse header `X-support-id`.

 
security:
  - apikeyAuth: []
  - Bearer: []

Grazie ragazzi

:inforge-rulez: