Example: Setting Up VOW Accounts
Spark's VOW support allows consumers to log in to your portal to create their own searches. To make use of this feature, you must create both a portal and a VOW account for each contact you'd like to offer this service to.
- Authentication
- Create your portal
- Create a VOW account for an existing contact
- Retrieve your Portal Name for the URI
- Generate the URI to your portal's OAuth 2 endpoint
Step 1: Authentication
This example expects that you have already obtained an OAuth 2 authorization token to access a user's data. Read more on our OpendID Connect Authentication and OAuth 2 Authorization.
Step 2: Create your portal
If you do not yet have a portal created, create one by supplying a portal name or the Portal Creation service.
$ curl "https://sparkapi.com/v1/portal" -H "Authorization: OAuth MY_OAUTH2_ACCESS_TOKEN" -H 'Content-Type: application/json' -X POST --data '{ "D": { "DisplayName": "GreatPortal", "Enabled": true } }'
{
"D": {
"Success": true
}
}
Step 3: Create a VOW account for an existing contact
Once your portal is created, you'll need to attach a VOW account to a contact, if it doesn't have one already. To create one, send a LoginName and Password to the Contact Portal service.
$ curl "https://sparkapi.com/v1/contacts/<Contact.Id>/portal" -H "Authorization: OAuth MY_OAUTH2_ACCESS_TOKEN" -H 'Content-Type: application/json' -X POST --data '{ "D": { "LoginName": "Johnny Everyman", "Password": "MyPassw0rd" } }'
{
"D": {
"Success": true
}
}
Step 4: Retrieve your Portal Name for the URI
While you supplied a DisplayName for your portal in step two, you'll need to retrieve auto-generated Name attribute to assemble the authorization endpoint to send VOW users to. You'll notice that, while we provided the DisplayName GreatPortal, the system generated the name greatportal for us to use in the URI.
$ curl "https://sparkapi.com/v1/portal" -H "Authorization: OAuth MY_OAUTH2_ACCESS_TOKEN"
{
"D": {
"ResourceUri": "/v1/portal/20100912153422758914000000",
"Id": "20100912153422758914000000",
"OwnerId": "20110000000000000000000001",
"ModificationTimestamp": 2011-11-18T16:35:43,
"Name": "greatportal",
"DisplayName": "GreatPortal",
"Enabled": true,
"RequiredFields": ["Address", "Phone"]
}
}
Step 5: Generate the URI to your portal's OAuth 2 endpoint
Using the portal name above, attach that to the OAuth 2 VOW Endpoint as follows:
https://sparkplatform.com/auth/vow/greatportal
From here, the consumer will begin the OAuth 2 flow.