code: def resolve_token(
      name,
      token_prefix,
      obj,
      authorize,
      given_token,
      generate_new_token,
      is_project,
  ):
      # 1) retrieve the previous deployment, if one exists
      workflow = ArgoWorkflows.get_existing_deployment(name)
      if workflow is None:
          obj.echo(
              "It seems this is the first time you are deploying *%s* to "
              "Argo Workflows." % name
          )
          prev_token = None
      else:
          prev_user, prev_token = workflow
  
      # 2) authorize this deployment
      if prev_token is not None:
          if authorize is None:
              authorize = load_token(token_prefix)
          elif authorize.startswith("production:"):
              authorize = authorize[11:]
  
          # we allow the user who deployed the previous version to re-deploy,
          # even if they don't have the token
          if prev_user != get_username() and authorize != prev_token:
              obj.echo(
                  "There is an existing version of *%s* on Argo Workflows which was "
                  "deployed by the user *%s*." % (name, prev_user)
              )
              obj.echo(
                  "To deploy a new version of this flow, you need to use the same "
                  "production token that they used. "
              )
              obj.echo(
                  "Please reach out to them to get the token. Once you have it, call "
                  "this command:"
              )
              obj.echo(
                  "    argo-workflows create --authorize MY_TOKEN",
                  fg="green",
              )
              obj.echo(
                  'See "Organizing Results" at docs.metaflow.org for more information '
                  "about production tokens."
              )
              raise IncorrectProductionToken(
                  "Try again with the correct production token."
              )
  
      # 3) do we need a new token or should we use the existing token?
      if given_token:
          if is_project:
              # we rely on a known prefix for @project tokens, so we can't
              # allow the user to specify a custom token with an arbitrary prefix
              raise MetaflowException(
                  "--new-token is not supported for @projects. Use --generate-new-token "
                  "to create a new token."
              )
          if given_token.startswith("production:"):
              given_token = given_token[11:]
          token = given_token
          obj.echo("")
          obj.echo("Using the given token, *%s*." % token)
      elif prev_token is None or generate_new_token:
          token = new_token(token_prefix, prev_token)
          if token is None:
              if prev_token is None:
                  raise MetaflowInternalError(
                      "We could not generate a new token. This is unexpected. "
                  )
              else:
                  raise MetaflowException(
                      "--generate-new-token option is not supported after using "
                      "--new-token. Use --new-token to make a new namespace."
                  )
          obj.echo("")
          obj.echo("A new production token generated.")
      else:
          token = prev_token
  
      obj.echo("")
      obj.echo("The namespace of this production flow is")
      obj.echo("    production:%s" % token, fg="green")
      obj.echo(
          "To analyze results of this production flow add this line in your notebooks:"
      )
      obj.echo('    namespace("production:%s")' % token, fg="green")
      obj.echo(
          "If you want to authorize other people to deploy new versions of this flow to "
          "Argo Workflows, they need to call"
      )
      obj.echo(
          "    argo-workflows create --authorize %s" % token, fg="green"
      )
      obj.echo(
          "when deploying this flow to Argo Workflows for the first time."
      )
      obj.echo(
          'See "Organizing Results" at https://docs.metaflow.org/ for more '
          "information about production tokens."
      )
      obj.echo("")
      store_token(token_prefix, token)
      return token
  
imports: import base64
  import json
  import platform
  import re
  import sys
  from hashlib import sha1
  from metaflow import JSONType, current, decorators, parameters
  from metaflow._vendor import click
  from metaflow.exception import MetaflowException, MetaflowInternalError
  from metaflow.metaflow_config import ARGO_WORKFLOWS_UI_URL, KUBERNETES_NAMESPACE, SERVICE_VERSION_CHECK, UI_URL
  from metaflow.package import MetaflowPackage
  from metaflow.plugins.aws.step_functions.production_token import load_token, new_token, store_token
  from metaflow.plugins.environment_decorator import EnvironmentDecorator
  from metaflow.plugins.kubernetes.kubernetes_decorator import KubernetesDecorator
  from metaflow.tagging_util import validate_tags
  from metaflow.util import get_username, to_bytes, to_unicode, version_parse
  from .argo_workflows import ArgoWorkflows
label_desc: Use image node_id 8 for calling a global function with example usage: resolve_token(name, token_prefix, obj, authorize, given_token, generate_new_token, is_project) and returns: token