Python Url Function

Overview

The url function provides a way to securely access external web resources (data and services) in a way that can be easily shared.

Scripts

The following script demonstrates importing the url function and retrieving data from a given URL.

from davinci.python import url data = url('https://server.com/data.json')

Authentication Mechanism

The url function will send authentication information to any server that it contacts, if that information has been configured for the desired server.

  • .env file - authenticaion tokens can be set up in the standard .env envirnoment variable file
  • davinci platform tokens - for users with an account on the davinci platform, any tokens that are configure on the platform will be included in requests made with the url function, if the user has logged into the platform prior to running their code.

Security

Security on davinci is managed through the use of tokens, each of which consists of the following three pieces of information.

  • url - the url is the URL of the resource being protected. It is either the full URL of it can be the first part of the URL. That is, whenever you access a URL for which consists of the specified URL plus and additional path, the token is active.
  • key
  • value - a value associated with the specified key.

Tokens used by your web desktop is managed using the profile app.

When using the davinci framework in Visual Studio, you have two options for managing your tokens. If you have defined tokens using the profile app on the davinci server, when you log into the davinci servers, your tokens will be imported into your environment and used by the url function when retrieving resources.