Skip to content

Instantly share code, notes, and snippets.

@srinivasanagandla-okta
Last active August 29, 2015 14:00
Show Gist options
  • Save srinivasanagandla-okta/452470c14e5850b36f69 to your computer and use it in GitHub Desktop.
Save srinivasanagandla-okta/452470c14e5850b36f69 to your computer and use it in GitHub Desktop.
Enroll and Poll (for Push Factor)

Enroll, Poll Flow

Enroll the factor

Request

POST /api/v1/users/00TmqQCMPRSYHBDHVWAN/factors HTTP/1.1
Host: your-subdomain.okta.com
Authorization: SSWS yourtoken
Accept: application/json
Content-Type: application/json
{
    "factorType": "push",
    "provider" : "duo",
    "deviceType" : "smartphone:ios",
    "profile": {
        "deviceName": "My iPhone"
    }
}

Response

HTTP/1.1 301 MOVED PERMANENTLY
Location: http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO
Content-Type: application/json
{
    "id" : "00ud4tVDDXYVKPXKVLCO",
    "factorType" : "push",
    "status" : "PENDING_ACTIVATION",
    "expiresAt" : "2013-06-24T17:39:18.000Z",
    "created" : "2013-06-24T16:39:18.000Z",
    "activated" : "null",
    "lastVerification" : "null",
    "lastUpdated" : "2013-07-02T21:36:25.344Z",
    "profile": {
         "deviceName": "My iPhone"
     },
     "_embedded" : {
           "install" : {
               "appStore" : "<link-to-the-push-app>",
               "barcode" : "<bar-code-that-has-to-be-scanned-by-the-app-to-register">           
           },
      },
     "_links": {
        "next" : {
             "name":"poll",
             "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO",
             "hints": {
                "allow": ["GET"]
            }
        },
        "self": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO",
            "hints": { 
                "allow": ["GET", "DELETE"]
            }
        },
       
        "poll": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO",
            "hints": {
                "allow": ["GET"]
            }
        },
        "user": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN",
            "hints": {
                "allow": ["GET"]
            }
        },
        "provider": {
            "href": "http://rain.okta1.com:1802/api/v1/factors/providers/duo",
            "hints": {
                "allow": ["GET"]
            }
         }
}

Get/Poll Status of the SMS Factor

Poll before it was activated

GET /api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO HTTP/1.1
Host: your-subdomain.okta.com
Authorization: SSWS yourtoken
Accept: application/json
Content-Type: application/json

Response

{
    "id" : "00ud4tVDDXYVKPXKVLCO",
    "factorType" : "push",
    "status" : "PENDING_ACTIVATION",
    "expiresAt" : "2013-06-24T17:39:18.000Z",
    "created" : "2013-06-24T16:39:18.000Z",
    "activated" : "null",
    "lastVerification" : "null",
    "lastUpdated" : "2013-07-02T21:36:25.344Z",
     "profile": {
              "deviceName": "My iPhone"
           },
      "_links": {
        "next" : {
            "name":"poll",
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO",
            "hints": {
                "allow": ["GET"]
            }
        },
        "self": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO",
            "hints": { 
                "allow": ["GET", "DELETE"]
            }
        },
        "poll": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO",
            "hints": {
                "allow": ["GET"]
            }
        },
        "user": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN",
            "hints": {
                "allow": ["GET"]
            }
        },
        "provider": {
            "href": "http://rain.okta1.com:1802/api/v1/factors/providers/00TmqQCMPRSYHBDHVWAN",
            "hints": {
                "allow": ["GET"]
            }
         }    
}

Poll after it was activated

GET /api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO HTTP/1.1
Host: your-subdomain.okta.com
Authorization: SSWS yourtoken
Accept: application/json
Content-Type: application/json

Response

{
    "id" : "00ud4tVDDXYVKPXKVLCO",
    "factorType" : "push",
    "status" : "ACTIVATED",
    "created" : "2013-06-24T16:39:18.000Z",
    "activated" : "2013-06-24T22:39:18.000Z",
    "lastVerification" : "2013-06-24T22:39:18.000Z",
    "lastUpdated" : "2013-06-24T22:39:18.000Z",
    "profile": {
              "deviceName": "My iPhone"
           },
     "_links": {
        "self": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO",
            "hints": { 
                "allow": ["GET", "DELETE"]
            }
        },
        "deactivate": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO/lifecycle/deactivate",
            "hints": {
                "allow": ["POST"]
            }
        },
        "user": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN",
            "hints": {
                "allow": ["GET"]
            }
        },
        "provider": {
            "href": "http://rain.okta1.com:1802/api/v1/factors/providers/00TmqQCMPRSYHBDHVWAN",
            "hints": {
                "allow": ["GET"]
            }
         }    
}

Poll for a factor that was never activated

GET /api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO HTTP/1.1
Host: your-subdomain.okta.com
Authorization: SSWS yourtoken
Accept: application/json
Content-Type: application/json

Response

{
    "id" : "00ud4tVDDXYVKPXKVLCO",
    "factorType" : "push",
    "status" : "EXPIRED",
    "created" : "2013-06-24T16:39:18.000Z",
    "expired" : "2013-06-24T22:39:18.000Z",
    "lastVerification" : null,
    "lastUpdated" : "2013-06-24T22:39:18.000Z",
    "profile": {
              "deviceName": "My iPhone"
           },
     "_links": {
        "self": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO",
            "hints": { 
                "allow": ["GET", "DELETE"]
            }
        },
        "activate": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN/factors/00ud4tVDDXYVKPXKVLCO/lifecycle/activate",
            "hints": {
                "allow": ["POST"]
            }
        },
        "user": {
            "href": "http://rain.okta1.com:1802/api/v1/users/00TmqQCMPRSYHBDHVWAN",
            "hints": {
                "allow": ["GET"]
            }
        },
        "provider": {
            "href": "http://rain.okta1.com:1802/api/v1/factors/providers/00TmqQCMPRSYHBDHVWAN",
            "hints": {
                "allow": ["GET"]
            }
         }    
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment