blockvis / civic-sip-php

Add Civic authorization to any PHP application. Framework agnostic PHP client for Civic Secure Identity Platform.
https://blockvis.com
MIT License
11 stars 3 forks source link

Problem in PHP and javascript integration #3

Closed navin9841 closed 6 years ago

navin9841 commented 6 years ago

i have completed civic's basic signup option in my browser but can't get user's data. can you please help me??

Here is my code. this appId is example code var civicSip = new civic.sip({ appId: 'ABC123' });

var button = document.querySelector('#signupButton'); var list=button.addEventListener('click', function () { civicSip.signup({ style: 'popup', scopeRequest: civicSip.ScopeRequests.BASIC_SIGNUP

});

});

In above step i have completed BASIC signup option in my browser and get QR code and browser and mobile app is already integrated in website . But how to get JSON List after user is fully verified i have read documentation here ,

Link: civic https://docs.civic.com/?javascript#ScopeRequests

How to fetch user' basic account info in JSON , i can't get perfect example in docs , Please help me .

Docs says that "The BASIC_SIGNUP scope request returns the user’s basic account info - email and phone. It is most commonly used for secure login and signup solutions when no additional identity verification is required."

i need to get Label DATA in my Browser . Can you help me ? my step is given below . In website

  1. I got QR code using basic signup process link: https://prnt.sc/j5o63a
  2. I have already downloaded civic app in my android device , When i open civic app in my mobile device , Device successfully connected with civic basic signup process.
  3. Successfully authorized (verified ) user .

After below code , How to get verified user's data in javascript ?.

I think browser response is true , Here is snapshot link .

http://prntscr.com/j5oa78.

Next, I have read this civic-sip-php from github and api-documentation , I fetch another problem, point . In my laravel project
I have installed composer packages , and already run composer require blockvis/civic-sip-php Implement User-Agent (Browser) functionality already integrated in my java-script code

In this github Docs point no. 4. Implement Application server functionality

In laravel code implementation ,where to keep . this code in laravel 5.6 . Code is given below use Blockvis\Civic\Sip\AppConfig; use Blockvis\Civic\Sip\Client;

// Configure Civic App credentials. $config = new AppConfig( 'Your Application ID', 'Your Application Secret', 'Your Application Private Signing Key' );

// Instantiate Civic API client with config and HTTP client. $sipClient = new Client($config, new \GuzzleHttp\Client());

// Exchange Civic authorization code for requested user data. $userData = $sipClient->exchangeToken($jwtToken);

I am waiting response .

cheelahim commented 6 years ago

Hello @navin9841. Thank you for your interest in the project. Note that this library is provided as a composer package, so you need to integrate it into laravel (or any other framework) yourself. Laravel integration is really depends on your application architecture so I refrain myself from recommending any specific implementation. Note that after you received the auth code in your browser, you need to implement AJAX request to your app server (which runs Laravel) and send this auth code (http://prntscr.com/j5oa78). As for the testing purposes this could be implemented simply inside a route handler:

use Blockvis\Civic\Sip\AppConfig;
use Blockvis\Civic\Sip\Client;

Route::post('/civic-test', function (Request $request) {

    $jwtToken = $request->get('<auth code key in post data>');

    // Configure Civic App credentials.
    $config = new AppConfig(
        'Your Application ID',
        'Your Application Secret',
        'Your Application Private Signing Key'
    );

    // Instantiate Civic API client with config and HTTP client.
    $sipClient = new Client($config, new \GuzzleHttp\Client());

    // Exchange Civic authorization code for requested user data.
    $userData = $sipClient->exchangeToken($jwtToken);

    // Extract the required data...
});
navin9841 commented 6 years ago

Thank you very much for your reply. I have implemented in my project .