Unable to setup Kubernetes dashboard in local windows 10 -401 unauthorized token error

I am trying to setup the kubernetes dashboard UI in my local windows 10 machine. I have followed the steps.
I am also able to generate the bearer token. But, after I am giving the token, it is throwing 401 unauthorized error. Kindly help me what could be the error. I followed the following youtube link to setup the dashboard UI. How to install Docker, Kubernetes, Kubernetes Dashboard UI - YouTube

Following the instructions from the official github repo mirrored what’s in this video and worked fine. My only guess is that you missed a step or did one of the steps wrong, like making a mistake when copy/pasting the token. Not sure if this is an issue in owershell, but in Mac and Linux, there isn’t a newline returned when getting the token. So I could see someone copying the terminal prompt by mistake with the token.

The service account that you’re getting the token of should be like this:

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kubernetes-dashboard
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kubernetes-dashboard

To get the token:

$ kubectl -n kubernetes-dashboard get sa/admin-user -o jsonpath="{.secrets[0].name}{'\n'}"
admin-user-token-n78wd

$ kubectl -n kubernetes-dashboard get secret admin-user-token-n78wd -o go-template="{{.data.token | base64decode}}"

This issue is caused by the token not being on one line.
Take it to sublime text and then edit there. You make also redirect the output into a file and then open the file to copy the output from it. best of luck