Unable to get anything via REST API - The access token has expired

Unable to get anything via REST API - The access token has expired

Unable to get anything via REST API - The access token has expired
Unable to get anything via REST API - The access token has expired
a week ago - last edited Friday
Tags: #API
Hardware Version:
Firmware Version: 6.2.0.12

hi all,

 

trying now to play with the Controller REST API - and I can't get any information due to "expired" token:

 

  1. I log in via https://controller/openapi/authorize/token?grant_type=client_credentials
    Result: 0, "Open API Get Access Token successfully", returned are the token and refresh token
  2. trying to get list of sites via https://controller/openapi/v1/$sOmadacId/sites?page=1&pageSize=10"
    Result: -44112, "The access token has expired. Please re-initiate the refreshToken process to obtain the access token."
  3. trying to refresh the token via https://controller/openapi/authorize/token?&grant_type=refresh_token"
    Result: 0, "Open API Get Access Token successfully", returned token and refresh token are the same as presious ones (at initial login)
  4. trying to get list of sites again via https://controller/openapi/v1/$sOmadacId/sites?page=1&pageSize=10"
    Result again: -44112, "The access token has expired. Please re-initiate the refreshToken process to obtain the access token."

 

what do I wrongly? what have I missed?

 

/BR ZoloNN ----------------------------------------------------------------------- Omada 2x ER605(UN) v2.0 + SG2008P(UN) V3.20 + SG2218 V1.20 + 2x SG2008 V4.20 + 3x EAP615-Wall(EU) V1.0 CET (GMT+1)
  0      
  0      
#1
Options
1 Accepted Solution
Re:Unable to get anything via REST API - The access token has expired-Solution
a week ago - last edited Friday

 

 

UPDATE: I have used the Access Token wrongly with the PowerShell Invoke-RestMethod command.

 

the header must be in format: 

$aHeaders = @{  'content-type' = 'application/json'; 'Authorization' = "AccessToken=$sAccessToken" }

 

and the Invoke-RestMethod must have the -SkipHeaderValidation paramether, otherwise you'll get following error: The format of value 'AccessToken=AT-xxxxxxxxxxxx' is invalid.

 

 

/BR ZoloNN ----------------------------------------------------------------------- Omada 2x ER605(UN) v2.0 + SG2008P(UN) V3.20 + SG2218 V1.20 + 2x SG2008 V4.20 + 3x EAP615-Wall(EU) V1.0 CET (GMT+1)
Recommended Solution
  0  
  0  
#2
Options
2 Reply
Re:Unable to get anything via REST API - The access token has expired-Solution
a week ago - last edited Friday

 

 

UPDATE: I have used the Access Token wrongly with the PowerShell Invoke-RestMethod command.

 

the header must be in format: 

$aHeaders = @{  'content-type' = 'application/json'; 'Authorization' = "AccessToken=$sAccessToken" }

 

and the Invoke-RestMethod must have the -SkipHeaderValidation paramether, otherwise you'll get following error: The format of value 'AccessToken=AT-xxxxxxxxxxxx' is invalid.

 

 

/BR ZoloNN ----------------------------------------------------------------------- Omada 2x ER605(UN) v2.0 + SG2008P(UN) V3.20 + SG2218 V1.20 + 2x SG2008 V4.20 + 3x EAP615-Wall(EU) V1.0 CET (GMT+1)
Recommended Solution
  0  
  0  
#2
Options
Re:Unable to get anything via REST API - The access token has expired
Friday

Hi  @ZoloNN 

 

Thanks for sharing the reason. I marked it as Solution; hope it helps others who may encounter the same situation.

  0  
  0  
#3
Options