Search code examples
laravel-5laravel-passport

Laravel passport client creation using code


Does anyone having idea about creating passport client using code as i can be able to create it using commands but how can i achieve it using code ???

Your help is highly appreciate.

Thanks in advance


Solution

  • I did it by my own and following is the snippet to generate the oAuth client manually by code.

    $oauth_client = new oAuthClient();
    $oauth_client->user_id =  $last_inserted_id;
    $oauth_client->name =  $user->name;
    $oauth_client->secret =base64_encode(hash_hmac('sha256',Hash::make($_REQUEST['password']), 'secret', true));
    $oauth_client->password_client=1;
    $oauth_client->personal_access_client   =  0;
    $oauth_client->redirect =  'redirect_uri';
    $oauth_client->revoked=  0;
    $oauth_client->save(); // Saving oauth client