How do I allow my users to sign in automatically into my ad store?
Trafficspaces has a great feature that allows your users to sign in seamlessly into your ad store if they are already signed in on your system.
Furthermore, if they haven't signed in yet, they will be redirected to your website to sign in.
Getting started
First of all, there are three components involved in the single signon process.
-
YOUR_LOGIN_ENDPOINT - this is the default sign in page on your site.You can set its URL as the value of the
loginurlkey in your General Preferences JSON configuration. -
YOUR_OAUTH_PROFILE_ENDPOINT - this is a server-side component that needs to be created by your developers. Its function is to
- generate unique single signon tokens per session, and
- send limited user info to Trafficspaces.
You can set its URL as the value of the oauthurl
key in your General Preferences JSON
configuration.
- TRAFFICSPACES_OAUTH_ENDPOINT - this is an
existing component that handles authentication on our side and
creates new user accounts automatically. Its URL is
http://<your_sub_domain>.trafficspaces.com/oauth.jsp
It should be straightforward to extend your system to support single-signon.To guide you, here are the processes that take place when new and existing users connect to your ad store.
Stage 1
- User clicks on a link on your site to visit the ad store e.g.
http://<your_sub_domain>.trafficspaces.com/store/. - Trafficspaces redirects the user to YOUR_LOGIN_ENDPOINT for authentication.
- If/when the user has been authenticated on your site, redirect
the user to
TRAFFICSPACES_OAUTH_ENDPOINT?token=xxxxx
- The
tokenshould be a unique value. It will be required later so store it in the user's server side session state, cookie, or other storage. - You can also pass an optional
timestampvalue which should contain the time the token was generated as a long integer. - For security reasons, you should make the token parameter expire in 60 seconds. It makes it harder for snooping devices to hijack and reuse the token.
- The
Stage 2
- Trafficspaces reads the token parameter.
- Trafficspaces sends an HTTP POST request to
YOUR_OAUTH_PROFILE_ENDPOINT
- The HTTP POST request will include the
tokenparameter and the optionaltimestampparameter. - In addition, any references to
{ts.oauth.token}and{ts.oauth.timestamp}in the YOUR_OAUTH_PROFILE_ENDPOINT URL will be replaced with thetokenandtimestampparameters respectively. This is useful if you want the parameters included in the request path
- The HTTP POST request will include the
- YOUR_OAUTH_PROFILE_ENDPOINT reads and
validates the
tokenparameter. - YOUR_OAUTH_PROFILE_ENDPOINT attempts to
resolve the user from the token.
- If the user is resolved successfully, it sends back the
user’s profile data in JSON format. Here is a
sample.
- If the user is resolved successfully, it sends back the
user’s profile data in JSON format. Here is a
sample.
{
"stat": "ok",
"profile": {
"identifier": "http://johndoe.abcwebsiteadvertising.com/",
"email": "johndoe@gmail.com",
"role": "ts_advertiser",
"name": {
"givenName": "John",
"familyName": "Doe"
},
"providerName": "ABC Website Advertising",
"displayName": "John Doe",
"gender": "male",
"companyName": "Acme Corporation",
"phoneNumber": "800-535-1234",
"url": "http://www.acme.com",
"address": {
"streetAddress": "542 Simpson Drive",
"city": "Newcastle",
"state": "Delaware",
"postalCode": "19720",
"country": "United States"
}
}
}
- If the user cannot be resolved, it sends a 403 response code.
-
The following fields are mandatory - stat, profile.identifier, and profile.email.
-
Trafficspaces reads the
identiferkey in the JSON data and using a hash function, it generates a user id on our system.- Very important: The identifier must be a static, globally unique value, which must also be sufficient to identify that user in your database. A URL such as the one in the sample which combines the user's unique ID and your domain name should suffice.
- Using the autogenerated user id in step 5, Trafficspaces checks
to see if the user’s account exists.
- If the account does not exists, it creates a new user account
with the profile information in the step 4a. The
rolekey may be set to ts_admin, ts_sales, ts_trafficker, ts_publisher, or ts_advertiser. The default value is ts_advertiser. - If the account already exists, Trafficspaces signs the user in automatically.
- If the account does not exists, it creates a new user account
with the profile information in the step 4a. The
That's it. If you have any questions or need assistance with integration, please open a new ticket and we'll be happy to help you out.