VssConnection not working getting : {"VS30063: You are not authorized to access https://dev.azure.com."} error using .Net 6.0

VssCredentials creds = new VssAadCredential(new VssAadToken("Bearer", accessToken)); // tried using this as well
//VssCredentials creds = new VssBasicCredential(string.Empty, accessToken); // tried using this as well
VssConnection connection = new VssConnection(new Uri("https://dev.azure.com/{organization}"), creds);
WorkItemTrackingHttpClient witClient = connection.GetClient<WorkItemTrackingHttpClient>();
Wiql query = new Wiql() { Query = "SELECT [Id], [Title], [State] FROM workitems WHERE [Work Item Type] = 'Bug' AND [Assigned To] = @Me" };
WorkItemQueryResult queryResults = witClient.QueryByWiqlAsync(query).Result;
When I am trying to execute the above code I am getting this error:
{"VS30063: You are not authorized to access https://dev.azure.com."}
When I am using .Net 6.0 I am getting this error but it is working for .Net 4.6.1