Bug 2160482

Summary: subscription-manager registration using access token fails with 'Restlib' object has no attribute 'close_connestion' error
Product: Red Hat Enterprise Linux 9 Reporter: Ramesh kumar <ramkumar>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED DUPLICATE QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 9.1   
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-01-12 16:35:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ramesh kumar 2023-01-12 15:01:12 UTC
Description of problem:

In RHEL 9.1, When we try to register a system using access token (generated using offline API token), it results in below error.

----------------------------
[root@xxxx ~]# subscription-manager register --token=$(curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token=$TOKEN | jq --raw-output .access_token)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3467  100  2731  100   736  11192   3016 --:--:-- --:--:-- --:--:-- 14151
'Restlib' object has no attribute 'close_connestion'
[root@xxxxx ~]# more /etc/redhat-release 
Red Hat Enterprise Linux release 9.1 (Plow)
---------------------------

But, a system profile gets created on Portal and the status of the system profile on portal shows as 'Disconnected or never checked-in'.


Version-Release number of selected component (if applicable):

RHEL 9.1
subscription-manager-rhsm-certificates-20220623-1.el9.noarch
libdnf-plugin-subscription-manager-1.29.30-1.el9.x86_64
python3-subscription-manager-rhsm-1.29.30-1.el9.x86_64
subscription-manager-1.29.30-1.el9.x86_64
Subscription-manager-cockpit-4-1.el9.noarch



How reproducible:
Easy

Steps to Reproduce:
1. Generate an offline token as from API Tokens page(https://access.redhat.com/management/api)


2. Use the offline token to generate an online access token as specified in article: https://access.redhat.com/articles/3626371

3. Use the generate online access token to register the RHEL 9.1 system using subscription-manager command.

# subscription-manager --token=ACCESS_TOKEN

OR You can run below register command and copy the offline token into refresh_token parameter in below command.

subscription-manager register --token=$(curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token="eyJh.." | jq --raw-output .access_token)





Actual results:

# subscription-manager register --token=$(curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token="eyJh.." | jq --raw-output .access_token)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3562  100  2823  100   739   5726   1498 --:--:-- --:--:-- --:--:--  7225
'Restlib' object has no attribute 'close_connestion'
[root@xxx xxxxx]# subscription-manager identity
This system is not yet registered. Try 'subscription-manager register --help' for more information.
[root@xxx xx]# 





Expected results:

We expect the registration to be successful.




Additional info:

We tested the same on RHEL 8.7 and RHEL 9.0 versions and the registration is successful. Below is the registration data from RHEL 9.0 version.

[root@xxxxxx ~]# rpm -qa | grep -i subscription-manager
subscription-manager-rhsm-certificates-1.29.26.1-1.el9_0.x86_64
libdnf-plugin-subscription-manager-1.29.26.1-1.el9_0.x86_64
python3-subscription-manager-rhsm-1.29.26.1-1.el9_0.x86_64
subscription-manager-1.29.26.1-1.el9_0.x86_64
subscription-manager-cockpit-1.29.26.1-1.el9_0.noarch
[root@xxxxxx ~]# 

[root@xxxxxxx ~]# subscription-manager clean
All local data removed
[root@xxxxxxx ~]# subscription-manager register --token=$(curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token="eyJhb..." | jq --raw-output .access_token)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3562  100  2823  100   739   3256    852 --:--:-- --:--:-- --:--:--  4103
The system has been registered with ID: xxxx-xxxxx-xxx-xxxxxxxxx
The registered system name is: xxxxxxx
[root@xxxxxxx ~]# 

Please do let us know if additional info is required.

Thanks

Comment 1 Pino Toscano 2023-01-12 16:35:07 UTC

*** This bug has been marked as a duplicate of bug 2120744 ***