Latest Legacy

Validate a session

This API validates a session.

API Endpoint

POST https://api.plivo.com/v1/Account/{auth_id}/Verify/Session/{session_uuid}/

Arguments

otp stringrequired

The OTP that you want to validate against a particular session.

Returns

Returns a JSON response containing the API request ID and session UUID.

Response

{
    "api_id": "e7af31b5-a7cb-40d6-a3ab-122fdcc9f0fe",
    "message": "session validated successfully.",
}

Example Request

1
2
3
4
5
6
7
8
9
10
11
import sys
sys.path.append("../plivo-python")
import plivo

client = plivo.RestClient('<auth_id>','<auth_token>')

response = client.verify_session.validate(
        session_uuid = '<session uuid>',
        otp='<otp value>')

print(response)
1
2
3
4
5
6
7
8
9
10
11
12
require "rubygems"
require "/usr/src/app/lib/plivo.rb"
include Plivo
#Environment
api = RestClient.new("<auth_id>", "<auth_token>")
begin
     puts("Validate Session")
     response = api.verify_session.validate('<session_uuid>','<otp>')
     puts response
rescue PlivoRESTError => e
     puts 'Exception: ' + e.message
end
1
2
3
4
5
6
7
let plivo = require('plivo')
let client = new plivo.Client('<auth_id>', '<auth_token>');
client.verify_session.validate({id:'<session_uuid>',otp:'<otp>'}).then(function(response) {
console.log(response)
}).catch(function (error) {
console.log(error)
});
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
require '/usr/src/app/vendor/autoload.php';
use Plivo\RestClient;
use Plivo\Exceptions\PlivoResponseException;

// ENVIRONMENT
$client = new RestClient("<auth_id>", "<auth_token>");


//Validate Session
try {
$response1 = $client->verifySessions->validate(
'<session_uuid>',
'<otp>'
);
print_r($response1);
}
catch (Exception $ex) {
print_r($ex);
}
?>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import com.plivo.api.Plivo;
import com.plivo.api.exceptions.PlivoRestException;
import com.plivo.api.models.verify_session.VerifySession;
import com.plivo.api.models.verify_session.VerifySessionList;
import com.plivo.api.models.verify_session.SessionCreateResponse;
import com.plivo.api.models.message.Message;
import com.plivo.api.exceptions.PlivoValidationException;
import com.plivo.api.models.base.ListResponse;

class Session {
  public static void main(String[] args) throws PlivoValidationException {
    Plivo.init("<auth_id>", "<auth_token>");
   try
    {
      SessionCreateResponse response = VerifySession.validation(
          "<session_uuid>", "<otp>") // Validation
        .create();
    System.out.println(response);
}
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
using System.Collections.Generic;
using Plivo;
using Plivo.Exception;
namespace dotnet_sdk
{
    class Session
    {
        static void Main(string[] args)
        {
            // ENVIRONMENT
            var api = new PlivoApi("<auth_id>", "<auth_token>");             
            // Validate Session
             try
             {   
                Console.WriteLine("Validate Session");
                var response = api.VerifySession.Validate(session_uuid:"<session_uuid>",otp:"<otp>");
                Console.WriteLine(response);
             }
catch (PlivoRestException e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }

}
}
}
1
2
3
4
5
6
curl -i --user auth_id:auth_token \
    -H "Content-Type: application/json" \
    -d '{ 
    "OTP": "<otp>"
}' \
    https://api.plivo.com/v1/Account/{auth_id}/Verify/Session/{session_uuid}/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main

import (
        "fmt"
        "encoding/json"

        "github.com/plivo/plivo-go"
)

func main() {
client, err := plivo.NewClient("<auth_id>", "<auth_token>", &plivo.ClientOptions{})
if err != nil {
fmt.Printf("Error:\n", err)
}

        //Validate
        response_validate, err := client.VerifySession.Validate(
                plivo.SessionValidationParams{
                        OTP: "<otp value>",
                }, "<SessionUUID>",
        )
        if err != nil {
                fmt.Print("Error", err.Error())
                return
        }
        res3, _ := json.Marshal(response_validate)
        fmt.Printf("Response Validation: \n\n %#v \n", string(res3))
}