"fly login" failed with "error: oauth2: cannot fetch token: 401 Unauthorized" in Tanzu Application Service (TAS) for VMs
search cancel

"fly login" failed with "error: oauth2: cannot fetch token: 401 Unauthorized" in Tanzu Application Service (TAS) for VMs

book

Article ID: 298112

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

"fly login" command sometimes fails with an authorization error as illustrated below:
$ ./fly --target tg1 login -n try --concourse-url http://concourse.example.com:80 -u admin -p 1234
logging in to team 'try'

WARNING:

fly version (6.5.1) is out of sync with the target (5.5.8). to sync up, run the following:

    ./fly -t tg1 sync

error: oauth2: cannot fetch token: 401 Unauthorized
Response: {"error":"invalid_client","error_description":"Invalid client credentials."}


Environment

Product Version: 2.9

Resolution

This is designed behavior if the local fly CLI version is very new (e.g. v6.x) while the target Concourse server version is old (e.g. v5.x).

Starting from fly CLI version 6.0, it's possible to run "fly sync" without logging into the Concourse server first.
$ fly -t tg1 logout
logged out of target: tg1

$ ./fly -v
6.5.1

$ ./fly sync -c http://concourse.example.com:80
downloading fly from http://concourse.example.com:80...

fly v5.5.8 [================================================] 19.0MiB/19.0MiB
done

$ ./fly -v
5.5.8