title: How does one retrieve the public_token for Plaid API in Python
body: <p>I'm trying to follow Plaid's documentation <a href="https://github.com/plaid/plaid-python" rel="nofollow noreferrer">from here</a> and I can't seem to figure out where do I get the <code>public_token</code> from when I'm working on Plaid <strong>development</strong> environment. They're saying that:</p>
  
  <p>In their second example:</p>
  
  <pre class="lang-py prettyprint-override"><code>from plaid import Client
  
  
  client = Client(client_id='***', secret='***', public_key='***', environment='sandbox')
  
  # the public token is received from Plaid Link
  response = client.Item.public_token.exchange(public_token)
  access_token = response['access_token']
  </code></pre>
  
  <p>I don't know where the <code>public_token</code> comes from. If I go to that <a href="https://github.com/plaid/link" rel="nofollow noreferrer">Plaid Link</a> they say:</p>
  
  <blockquote>
    <p>This repository is now deprecated. To integrate with Plaid, visit the
    docs. <a href="https://plaid.com/docs" rel="nofollow noreferrer">https://plaid.com/docs</a></p>
  </blockquote>
  
  <p>Then, when I go to their <a href="https://plaid.com/docs" rel="nofollow noreferrer">official docs</a> I can't seem to find any way of getting that <code>public token</code>.</p>
  
  <p>I'm trying to do something along these lines:</p>
  
  <pre class="lang-py prettyprint-override"><code>from exceptions import (
      InvalidPlaidEnvironment,
      MissingPlaidCredential
  )
  
  from plaid import Client
  from plaid.errors import APIError, ItemError, InvalidRequestError
  
  
  VALID_ENVIRONMENTS = (
      'sandbox',
      'development',
      'production'
  )
  
  CLIENT_ID = '&lt;development_client_id&gt;'
  SECRET = '&lt;development_secret&gt;'
  PUBLIC_KEY = '&lt;development_public_key&gt;'
  ENVIRONMENT = 'development'
  
  
  class PlaidProcessor:
      """
      Simple processor class for Plaid API
      """
  
      def __init__(
              self,
              client_id=CLIENT_ID,
              secret=SECRET,
              public_key=PUBLIC_KEY,
              environment=ENVIRONMENT
      ):
          """
          Constructor for PlaidProcessor. Initialize our class with basic credentials
          data.
  
          Args:
              client_id (str): Plaid client ID
              secret (str): Plaid secret
              public_key (str): Plaid public key
              environment (str): One of sandbox, development, or production
          """
  
          self.client_id = client_id
          self.secret = secret
          self.public_key = public_key
          self.environment = environment
  
          if not self.client_id:
              raise MissingPlaidCredential(
                  'Missing CLIENT_ID. Please provide Plaid client id.'
              )
  
          if not self.secret:
              raise MissingPlaidCredential(
                  'Missing SECRET. Please provide Plaid secret.'
              )
  
          if not self.public_key:
              raise MissingPlaidCredential(
                  'Missing PUBLIC_KEY. Please provide Plaid public key.'
              )
  
          if not self.environment:
              raise MissingPlaidCredential(
                  'Missing environment. Please provide Plaid environment.'
              )
  
          if self.environment.lower() not in VALID_ENVIRONMENTS:
              valid_environments_str = ','.join(VALID_ENVIRONMENTS)
  
              raise InvalidPlaidEnvironment(
                  f'Please insert one of the following environments: {valid_environments_str}'
              )
  
          self.client = Client(
              client_id=self.client_id,
              secret=self.secret,
              public_key=self.public_key,
              environment=self.environment
          )
  
          self.access_token = None
          self.public_token = None
  
      def get_public_token(self):
          # how do I get the access token?
          pass
  </code></pre>
  
  <p>In the docs, they're also specifying the following:</p>
  
  <blockquote>
    <p>A <code>public_token</code> (which is returned in your Link <code>onSuccess()</code> callback)
    should be passed to your server, which will exchange it for an
    <code>access_token</code>. public_tokens are one-time use tokens and expire after
    30 minutes. You can generate new public_tokens as needed via the
    /item/public_token/create endpoint.</p>
    
    <p>An <code>access_token</code> is used to access product data for an Item. This
    should be stored securely, and never in client-side code. This is used
    to make authenticated requests to the Plaid API for the user. By
    default, access_tokens do not expire, though you can rotate them; if
    it winds up in an error state, the access_token will work again if the
    Item’s error is resolved. Each access_token is unique to a specific
    Item, and cannot be used to access other Items.</p>
  </blockquote>
  
  <p>but this is just more confusing. Can anybody give me some advice regarding this?</p>