Students Creation API

Is there a documentation or example on how to use, if there is any, API so i can create students using the API?
I tried using the endpoints from the Android mobile application but i am not able to register users.

Hi @johnnyak,

You can use this url endpoint for the registration.

Hello @jramnai ,

Thank you for your reply.

I am able to register the user now, i am using the endpoint you are pointing to, i think it was some problem with access token that needs to be refreshed.
Which brings me to my next question.

Where can i read about best practice for the flow of register and login process?

I created a client at:
And i am using the client library to test things.

When i use my php script from the browser while logged in as admin, the user registration works and i am redirected back to the other website. But when i run the php script while not logged in i am taken to the Sign in page.

Below is the code i am using:

/=== START CODE ===/


require 'vendor/autoload.php';

use \League\OAuth2\Client\Provider\GenericProvider;

$provider = new \League\OAuth2\Client\Provider\GenericProvider([
    'clientId'                => 'my_client_id',    // The client ID assigned to you by the provider
    'clientSecret'            => 'my_client_secret',   // The client password assigned to you by the provider
    'redirectUri'             => '',
    'urlAuthorize'            => '',
    'urlAccessToken'          => '',
    'urlResourceOwnerDetails' => '',
    'scopes'                   => 'profile openid email permissions',
    'token_type' => 'jwt'

// If we don't have an authorization code then get one
if (!isset($_GET['code'])) {

    // Fetch the authorization URL from the provider; this returns the
    // urlAuthorize option and generates and applies any necessary parameters
    // (e.g. state).
    $authorizationUrl = $provider->getAuthorizationUrl();

    // Get the state generated for you and store it to the session.
    $_SESSION['oauth2state'] = $provider->getState();

    // Redirect the user to the authorization URL.
    header('Location: ' . $authorizationUrl);

// Check given state against previously stored one to mitigate CSRF attack
} elseif (empty($_GET['state']) || ($_GET['state'] !== $_SESSION['oauth2state'])) {

    exit('Invalid state');

} else {

    try {

        // Try to get an access token using the authorization code grant.
        $accessToken = $provider->getAccessToken('authorization_code', [
            'code' => $_GET['code']

        // We have an access token, which we may use in authenticated
        // requests against the service provider's API.
        echo $accessToken->getToken() . "\n";
        echo $accessToken->getRefreshToken() . "\n";
        echo $accessToken->getExpires() . "\n";
        echo ($accessToken->hasExpired() ? 'expired' : 'not expired') . "\n";

        // Using the access token, we may look up details about the
        // resource owner.
        $resourceOwner = $provider->getResourceOwner($accessToken);


        // The provider provides a way to get an authenticated API request for
        // the service, using the access token; it returns an object conforming
        // to Psr\Http\Message\RequestInterface.
        $postData = [
            'terms_of_service' => 'true',
            'honor_code' => 'true',
            'username' => 'student_username',
            'name' => 'Student Name',
            'email' => '',
            'country' => 'LB',
            'password' => 'student_password'
        $options = [
            'body' => http_build_query($postData),
            'headers' => [
                'Content-Type' => 'application/x-www-form-urlencoded',

        $request = $provider->getAuthenticatedRequest("POST", '', $accessToken, $options);
        $response = $provider->getParsedResponse($request);

    } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {

        // Failed to get the access token or user details.



I am glad that your are able to register your students using the API endpoint.

But for your another question it would be better if you create separate topic for it, so that in future people facing the same issue can look over there.

And regarding PHP I don’t have any idea. You may create new topic, may be someone familiar with it can help you.