Skip to content

Simple PHP examples demonstrating the use of the Janrain API for authentication and registration.

License

Notifications You must be signed in to change notification settings

JanrainMicah/janrain-native-api-examples

Repository files navigation

Native API Examples

Janrain's OAuth registration and authentication API endpoints have picked up the nickname "Native API" since they were designed for use within native desktop and mobile appliactions.

Using the Native API for web applications can offer a greater degree of control over the user registration and authentication flows at the cost of the convenience and simplicity of the Registration Javascript "widget" .

All examples are written in PHP.

Contents

Prerequisites

  • Janrain Social Login (aka Engage) application
  • Janrain Registration (aka Capture) application
  • PHP web server or local environment (eg. LAMP, MAMP, WAMP, etc.)

Getting Started

  1. Create a new Janrain Login API client using the /clients/add API call:

     curl -X POST \
     -d client_id=APPLICATION_OWNER_CLIENT_ID \
     -d client_secret=APPLICATION_OWNER_CLIENT_SECRET \
     -d description='Native API examples login client' \
     -d features='["login_client"]' \
     https://YOUR_APP.janraincapture.com/clients/add
    
  2. Add the default_flow_name setting to the login client you created in step 1 (The flow name is usually "standard" but check with your Janrain representative if in doubt):

     curl -X POST \
     -d client_id=APPLICATION_OWNER_CLIENT_ID \
     -d client_secret=APPLICATION_OWNER_CLIENT_SECRET \
     -d for_client_id=LOGIN_CLIENT_ID_FROM_STEP_1 \
     -d key=default_flow_name \
     -d value=standard \
     https://YOUR_APP.janraincapture.com/settings/set
    
  3. Add the default_flow_version setting to the login client you created in in step 1 (The flow version must be provided by your Janrain representative):

     curl -X POST \
     -d client_id=APPLICATION_OWNER_CLIENT_ID \
     -d client_secret=APPLICATION_OWNER_CLIENT_SECRET \
     -d for_client_id=LOGIN_CLIENT_ID_FROM_STEP_1 \
     -d key=default_flow_version \
     -d value=497f2277-a8ca-418e-a6dd-e7d30fabe7df \
     https://YOUR_APP.janraincapture.com/settings/set
    
  4. Download the source code or fork and clone this repository.

  5. Unzip the files into your web server root. For example:

     unzip janrain-native-api-examples-master.zip -d /var/www
    
  6. Rename config.example.php to config.php.

  7. Add the client ID and secret for login client you created in step 1 to the config.php file:

     define('JANRAIN_LOGIN_CLIENT_ID', 'Your client ID goes here');
     define('JANRAIN_LOGIN_CLIENT_SECRET', 'Your client secret goes here');
    
  8. Navigate to the examples folder in your web browser. Eg. http://localhost/janrain-native-api-examples-master/

Examples

Social Registration

Social Registration consists of a new user authenticating with an identity provider (Facebook, Google, etc.) as the first step in a 2-step process to register a new account. Janrain handles the interaction between the end-user and the identity provider using the appropriate protocol (OAuth 2.0/OpenID/SAML 2.0) to authenticate the user and obtain user data.

The second step is a registration form which ensures required data fields are collected from the user. The User Data can be used to pre-populate the registration form.

Social Registration Sequence Diagram

Reference Documentation

Social Sign In

Traditional Registration

Traditional Sign In

Social Merge Accounts

Traditional Merge Accounts

Account Linking

Edit Profile

Forgot Password

Verify Email

About

Simple PHP examples demonstrating the use of the Janrain API for authentication and registration.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •