The Not authorized to access group error occurs when the consumer group specified in your client configuration does not exist in ApsaraMQ for Kafka.
Cause
The consumer group referenced by the group.id property in your consumer configuration has not been created in the ApsaraMQ for Kafka console or through the API.
Solution
Create the consumer group by using one of the following methods.
Use the console
Create the consumer group in the ApsaraMQ for Kafka console. For detailed steps, see the "Step 2: Create a group" section in Step 3: Create resources.
Make sure the consumer group name matches the group.id value in your consumer configuration exactly.
Call the CreateConsumerGroup API
To create the consumer group programmatically, call the CreateConsumerGroup API operation.
Verify the fix
After you create the consumer group:
Restart your consumer client.
Check the consumer logs to confirm it joins the group without errors.
In the ApsaraMQ for Kafka console, go to the Consumer Groups page and verify that the consumer group is active.
The error persists after you create the consumer group
If you still see the Not authorized to access group error after creating the consumer group, check the following:
Instance mismatch: Verify that the consumer group was created on the same ApsaraMQ for Kafka instance that your consumer connects to.