code: func writeTokenFile(ctx context.Context, tokenFile *tokenserver.TokenFile, state *stateInToken, path string) error {
  	stateBlob, err := json.Marshal(state)
  	if err != nil {
  		logging.Errorf(ctx, "Failed to marshal tokend_state - %s", err)
  		return err
  	}
  	tokenFile.TokendState = stateBlob
  
  	out := bytes.Buffer{}
  	m := jsonpb.Marshaler{}
  	m.Indent = "  "
  	if err := m.Marshal(&out, tokenFile); err != nil {
  		logging.Errorf(ctx, "Failed to marshal the token file - %s", err)
  		return err
  	}
  	blob := out.Bytes()
  
  	return AtomicWriteFile(ctx, path, blob, 0644)
  }
docs: // writeTokenFile replaces the token file on disk.
  //
  // It updates tokenFile.TokendState field first, then serializes the token and
  // dumps it on disk.
  //
  // It replaces the token file atomically, retrying a bunch of times in case of
  // concurrent access errors (important on Windows).
  //
  // The token file is world-readable (0644 permissions).