cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements

ISE API Guest Portal Settings and Elements

3349
Views
3
Helpful
0
Comments

This document focuses around using the ISE API for working with portal settings and elements using the API for Guest & BYOD portals and flows. For guest/sponsor specific document see: ISE Guest Sponsor API Tips & Tricks.

Support

There are samples, however please note we can't comment on coding here, its on your own with outside support. Cisco does have a DevNet developer forum that might be able to assist further but this is above support here and with the TAC.

Where can I find information about the API?

Cisco Identity Services Engine API Reference Guide, Release 2.x - Introduction to External RESTful Services API [Cisco I…

 

Please see the API Reference for how to configure an ERS API user.

You will then be able to access

https://<ISE-ADMIN-NODE>:9060/ers/sdk

 

How can I set the access code for my portal?

Thanks to @hslai and @jpujol for this 

 

ISE 2.2+ has ERS API for Self Registered Portal and Sponsored Guest Portal.

  1. Set a Access Code via the ISE admin web UI.
  2. Use ERS API to get all portals for the particular type to find the ID
  3. Use the ID to get the details on the particular portal
  4. Copy the resulting details from (3) and change the accessCode data to a new data
  5. Copy the altered details and use that as the data for PUT to update the portal.

 

Use the browser extension called Postman or any other script to set the passcode on the hotspot portal using JSON:

PUT   https://<isePAN>:9060/ers/config/hotspotportal/{ID}   with :

 

"aupSettings" : {
            accessCode : “<codehere>”
}

Hotspot Portal (python 3.5.2)

"""
    Modify the ISE Hotspot portal Access Code
    tested on ISE 2.3.0.298, python 3.5.2
    requires the portal-id
"""
__author__      = "Jean-Francois Pujol, Cisco Switzerland"
__copyright__   = "free to be re-used as needed; Oct 2017"

import string, unicodedata, base64
import argparse
import requests
import json
requests.packages.urllib3.disable_warnings()
iseServer = "ise.rollelab.ch"
username = 'ersadmin'
password = ‘xxxxxx’ # plain password
baseUrl = 'https://' + iseServer + ':9060/ers/'

def setHeaders(username,password):
    authString = username + ':' + password
    b64AuthString = base64.b64encode(authString.encode('utf-8'))
    authHeader = 'Basic ' + b64AuthString.decode('utf-8')
    iseHeader = {'Authorization' : authHeader , 'Accept': 'application/json' , 'Content-Type': 'application/json'}
    return (iseHeader)

def main():
    # Script arguments
    parser = argparse.ArgumentParser(prog='setHotSpotAccessCode.py', description='Modify ISE portal Access Code ')
    parser.add_argument('--portalId', help='Guest portal ID', action='store',dest='portalID')
    parser.add_argument('--code', help='specify a new password', action='store',dest='aCode')
    args = parser.parse_args()

    if (args.portalID):
        portalID = args.portalID
    else:
        print('Error: missing --portalId argument')
        exit(-1)

    url = baseUrl + 'config/hotspotportal/' + portalID
    headers = setHeaders(username,password)
    req = requests.get(url, headers=headers, verify=False)
    if req.status_code != 200:
        print("Error; unable to get a correct answer; retcode = " + str(req.status_code) )
        exit(1)
    jsonData = req.json()

    try:
        oldAccessCode = jsonData['HotspotPortal']['settings']['aupSettings']['accessCode']
    except:
        print('error: no Access Code found in this portal')
        exit(1)

    print('Current access code : ' + oldAccessCode)

    if (args.aCode):
        aCode = args.aCode
    else:
        exit(0)

    jsonData['HotspotPortal']['settings']['aupSettings']['accessCode'] = aCode
    req = requests.put(url, headers=headers, data=json.dumps(jsonData), verify=False)

    if req.status_code != 200:
        print("Error; unable to set the new access code; retcode = " + str(req.status_code) )
        exit(1)

    print("Access code successfully set to : " + aCode)

    exit(0)

if __name__ == "__main__":

    main()

Hotspot Portal (python 2.7.6)

"""
    Modify the ISE Hotspot portal Access Code
    
    tested on ISE 2.3.0.298, python 2.7.6
    requires the portal-id 

"""

__author__      = "Jean-Francois Pujol, Cisco Switzerland"
__copyright__   = "free to be re-used as needed; Sep 2017"

import string, unicodedata, base64
import argparse
import requests
import json
requests.packages.urllib3.disable_warnings()
from pprint import pprint

iseServer = "ise.rollelab.ch"
username = 'ersadmin'
#password = 'xxxxxxxxxxxMjM=' # password encoded in base64
password = 'xxxxxx' # plain password 
baseUrl = 'https://' + iseServer + ':9060/ers/'

def main():
    
    # Script arguments
    parser = argparse.ArgumentParser(prog='setHotSpotAccessCode.py', description='Modify ISE portal Access Code ')
    parser.add_argument('--portalId', help='Guest portal ID', action='store',dest='portalID')
    parser.add_argument('--code', help='specify a new password', action='store',dest='aCode')

    args = parser.parse_args()
    
    if (args.portalID):
        portalID = args.portalID
    else:
        print('Error: missing --portalId argument')
        exit(-1)

    url = baseUrl + 'config/hotspotportal/' + portalID
    auth_string = 'Basic ' + base64.b64encode(username + ':' + password)
    #auth_string = 'Basic ' + base64.b64encode(username + ':' + password.decode('base64'))
    headers = { 'Authorization' : auth_string, 'Accept' : 'application/json', 'Content-Type' : 'application/json' }

    req = requests.get(url, headers=headers, verify=False)
    if req.status_code != 200:
        print("Error; unable to get a correct answer; retcode = " + str(req.status_code) )
        exit(1)
    
    jsonData = req.json()
    
    try:
        oldAccessCode = jsonData['HotspotPortal']['settings']['aupSettings']['accessCode'].encode('ascii')
    except:
        print('error: no Access Code found in this portal')
        exit(1)
    
    print('Current access code : ' + oldAccessCode)
    
    if (args.aCode):
        aCode = args.aCode
    else:
        exit(0)
    
    jsonData['HotspotPortal']['settings']['aupSettings']['accessCode'] = aCode.encode('utf-8')
    
    req = requests.put(url, headers=headers, data=json.dumps(jsonData), verify=False)
    
    if req.status_code != 200:
        print("Error; unable to set the new access code; retcode = " + str(req.status_code) )
        exit(1)
    
    print("Access code successfully set to : " + aCode)
    
    exit(0)

if __name__ == "__main__":
    main()

Credentialed Guest Portal (python 2.7.6)

"""
    Modify the ISE guest portal Access Code
    tested on ISE 2.2.0.470, python 2.7.6
    requires the portal-id 
"""

__author__      = "Jean-Francois Pujol, Cisco Switzerland"
__copyright__   = "free to be re-used as needed; Apr 2017"

import string, unicodedata, base64
import argparse
import requests
import json
requests.packages.urllib3.disable_warnings()

iseServer = "ise.rollelab.ch"
username = 'ersadmin'
password = 'cisco' # plain password 
baseUrl = 'https://' + iseServer + ':9060/ers/'

def main():
    
    # Script arguments
    parser = argparse.ArgumentParser(prog='setAccessCode.py', description='Modify ISE portal Access Code ')
    parser.add_argument('--portalId', help='Guest portal ID', action='store',dest='portalID')
    parser.add_argument('--code', help='specify a new password', action='store',dest='aCode')

    args = parser.parse_args()
    
    if (args.portalID):
        portalID = args.portalID
    else:
        print('Error: missing --portalId argument')
        exit(-1)

    url = baseUrl + 'config/sponsoredguestportal/' + portalID
    auth_string = 'Basic ' + base64.b64encode(username + ':' + password)
    headers = { 'Authorization' : auth_string, 'Accept' : 'application/json', 'Content-Type' : 'application/json' }

    req = requests.get(url, headers=headers, verify=False)
    if req.status_code != 200:
        print("Error; unable to get a correct answer; retcode = " + str(req.status_code) )
        exit(1)
    
    jsonData = req.json()
    try:
        oldAccessCode = jsonData['SponsoredGuestPortal']['settings']['selfRegPageSettings']['registrationCode'].encode('ascii')
    except:
        print('error: no Access Code found in this portal')
        exit(1)
    
    print('Current access code : ' + oldAccessCode)
    
    if (args.aCode):
        aCode = args.aCode
    else:
        exit(0)
    
    jsonData['SponsoredGuestPortal']['settings']['selfRegPageSettings']['registrationCode'] = aCode.encode('utf-8')
    
    req = requests.put(url, headers=headers, data=json.dumps(jsonData), verify=False)
    
    if req.status_code != 200:
        print("Error; unable to set the new access code; retcode = " + str(req.status_code) )
        exit(1)
    
    print("Access code successfully set to : " + aCode)
    
    exit(0)

if __name__ == "__main__":
    main()

 

Create
Recognize Your Peers
Content for Community-Ad