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 = StepFunctions.get_existing_deployment(name)
      if workflow is None:
          obj.echo(
              "It seems this is the first time you are deploying *%s* to "
              "AWS Step Functions." % 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 AWS Step "
                  "Functions 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(
                  "    step-functions 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 AWS Step Functions, they need to call"
      )
      obj.echo(
          "    step-functions create --authorize %s" % token, fg="green"
      )
      obj.echo(
          "when deploying this flow to AWS Step Functions 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
  from metaflow._vendor import click
  from hashlib import sha1
  import json
  import re
  from metaflow import current, decorators, parameters, JSONType
  from metaflow.metaflow_config import SERVICE_VERSION_CHECK, SFN_STATE_MACHINE_PREFIX, UI_URL
  from metaflow.exception import MetaflowException, MetaflowInternalError
  from metaflow.package import MetaflowPackage
  from metaflow.plugins.aws.batch.batch_decorator import BatchDecorator
  from metaflow.tagging_util import validate_tags
  from metaflow.util import get_username, to_bytes, to_unicode, version_parse
  from .step_functions import StepFunctions
  from .production_token import load_token, store_token, new_token
label_desc: Use image node_id 7 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