---
"@context": https://schema.org
"@type": TechArticle
"@id": https://www.twilio.com/docs/verify/api/access-token#article
headline: Access Token Resource
description: Full API reference for the Access Token resource in the Twilio Verify API. Sample code shows how to create and fetch Access Tokens.
url: https://www.twilio.com/docs/verify/api/access-token
inLanguage: en
dateModified: 2026-03-09T18:47:22.000Z
author:
  "@type": Organization
  name: Twilio Developer Education Team
publisher:
  "@type": Organization
  name: Twilio
---

# Access Token Resource

Your client side application uses the `AccessToken` resource to authenticate its request to the Verify Push API when creating (i.e., enrolling or registering) an [Entity](/docs/verify/api/entity) and/or [Factor](/docs/verify/api/factor).

> \[!NOTE]
>
> While this Verify Push `AccessToken` resource is similar to those used by [Twilio voice/chat/video products](/docs/iam/access-tokens), it cannot be reused between them.

## AccessToken Properties

<OperationTable type="properties" data={{"type":"object","refName":"verify.v2.service.access_token","modelName":"verify_v2_service_access_token","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^YK[0-9a-fA-F]{32}$","nullable":true,"description":"A 34 character string that uniquely identifies this Access Token."},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The unique SID identifier of the Account."},"service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^VA[0-9a-fA-F]{32}$","nullable":true,"description":"The unique SID identifier of the Verify Service."},"entity_identity":{"type":"string","nullable":true,"description":"The unique external identifier for the Entity of the Service."},"factor_type":{"type":"string","enum":["push"],"description":"The Type of the Factor. Currently only `push` is supported.","refName":"access_token_enum_factor_types","modelName":"access_token_enum_factor_types"},"factor_friendly_name":{"type":"string","nullable":true,"description":"A human readable description of this factor, up to 64 characters. For a push factor, this can be the device's name.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"token":{"type":"string","nullable":true,"description":"The access token generated for enrollment, this is an encrypted json web token."},"url":{"type":"string","format":"uri","nullable":true,"description":"The URL of this resource."},"ttl":{"type":"integer","default":0,"description":"How long, in seconds, the access token is valid. Max: 5 minutes"},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date that this access token was created, given in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format."}}}} />

## Create an AccessToken resource

`POST https://verify.twilio.com/v2/Services/{ServiceSid}/AccessTokens`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The unique SID identifier of the Service.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^VA[0-9a-fA-F]{32}$"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"CreateAccessTokenRequest","required":["Identity","FactorType"],"properties":{"Identity":{"type":"string","description":"The unique external identifier for the Entity of the Service. This identifier should be immutable, not PII, and generated by your external system, such as your user's UUID, GUID, or SID."},"FactorType":{"type":"string","enum":["push"],"description":"The Type of the Factor. Currently only `push` is supported.","refName":"access_token_enum_factor_types","modelName":"access_token_enum_factor_types"},"FactorFriendlyName":{"type":"string","description":"The friendly name of the factor that is going to be created with this access token","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"Ttl":{"type":"integer","description":"How long, in seconds, the access token is valid. Can be an integer between 60 and 300. Default is 60."}}},"examples":{"createWithTtl":{"value":{"lang":"json","value":"{\n  \"FactorType\": \"push\",\n  \"FactorFriendlyName\": \"John Doe iPhone\",\n  \"Identity\": \"ff483d1ff591898a9942916050d2ca3f\",\n  \"Ttl\": 300\n}","meta":"","code":"{\n  \"FactorType\": \"push\",\n  \"FactorFriendlyName\": \"John Doe iPhone\",\n  \"Identity\": \"ff483d1ff591898a9942916050d2ca3f\",\n  \"Ttl\": 300\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"FactorType\"","#7EE787"],[":","#C9D1D9"]," ",["\"push\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"FactorFriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"John Doe iPhone\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Identity\"","#7EE787"],[":","#C9D1D9"]," ",["\"ff483d1ff591898a9942916050d2ca3f\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Ttl\"","#7EE787"],[":","#C9D1D9"]," ",["300","#79C0FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117","colorScheme":"dark"}}},"createWithTtl200":{"value":{"lang":"json","value":"{\n  \"FactorType\": \"push\",\n  \"FactorFriendlyName\": \"John Doe iPhone\",\n  \"Identity\": \"ff483d1ff591898a9942916050d2ca3f\",\n  \"Ttl\": 300\n}","meta":"","code":"{\n  \"FactorType\": \"push\",\n  \"FactorFriendlyName\": \"John Doe iPhone\",\n  \"Identity\": \"ff483d1ff591898a9942916050d2ca3f\",\n  \"Ttl\": 300\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"FactorType\"","#7EE787"],[":","#C9D1D9"]," ",["\"push\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"FactorFriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"John Doe iPhone\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Identity\"","#7EE787"],[":","#C9D1D9"]," ",["\"ff483d1ff591898a9942916050d2ca3f\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Ttl\"","#7EE787"],[":","#C9D1D9"]," ",["300","#79C0FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117","colorScheme":"dark"}}},"createWithoutTtl":{"value":{"lang":"json","value":"{\n  \"FactorType\": \"push\",\n  \"FactorFriendlyName\": \"John Doe iPhone\",\n  \"Identity\": \"ff483d1ff591898a9942916050d2ca3f\"\n}","meta":"","code":"{\n  \"FactorType\": \"push\",\n  \"FactorFriendlyName\": \"John Doe iPhone\",\n  \"Identity\": \"ff483d1ff591898a9942916050d2ca3f\"\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"FactorType\"","#7EE787"],[":","#C9D1D9"]," ",["\"push\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"FactorFriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"John Doe iPhone\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Identity\"","#7EE787"],[":","#C9D1D9"]," ",["\"ff483d1ff591898a9942916050d2ca3f\"","#A5D6FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117","colorScheme":"dark"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Create a new enrollment Access Token for the Entity

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

async function createAccessToken() {
  const accessToken = await client.verify.v2
    .services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .accessTokens.create({
      factorType: "push",
      identity: "Identity",
    });

  console.log(accessToken.sid);
}

createAccessToken();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
client = Client(api_key, api_secret, account_sid)

access_token = client.verify.v2.services(
    "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).access_tokens.create(identity="Identity", factor_type="push")

print(access_token.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID at twilio.com/console
        // Provision API Keys at twilio.com/console/runtime/api-keys
        // and set the environment variables. See http://twil.io/secure
        // For local testing, you can use your Account SID and Auth token
        string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
        string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

        TwilioClient.Init(apiKey, apiSecret, accountSid);

        var accessToken = await AccessTokenResource.CreateAsync(
            identity: "Identity",
            factorType: AccessTokenResource.FactorTypesEnum.Push,
            pathServiceSid: "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(accessToken.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.AccessToken;

public class Example {
    // Find your Account SID at twilio.com/console
    // Provision API Keys at twilio.com/console/runtime/api-keys
    // and set the environment variables. See http://twil.io/secure
    // For local testing, you can use your Account SID and Auth token
    public static final String API_KEY = System.getenv("TWILIO_API_KEY");
    public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

    public static void main(String[] args) {
        Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);
        AccessToken accessToken =
            AccessToken.creator("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "Identity", AccessToken.FactorTypes.PUSH)
                .create();

        System.out.println(accessToken.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	verify "github.com/twilio/twilio-go/rest/verify/v2"
	"os"
)

func main() {
	// Find your Account SID at twilio.com/console
	// Provision API Keys at twilio.com/console/runtime/api-keys
	// and set the environment variables. See http://twil.io/secure
	// For local testing, you can use your Account SID and Auth token
	accountSid := os.Getenv("TWILIO_ACCOUNT_SID")
	apiKey := os.Getenv("TWILIO_API_KEY")
	apiSecret := os.Getenv("TWILIO_API_SECRET")
	client := twilio.NewRestClientWithParams(twilio.ClientParams{
		Username:   apiKey,
		Password:   apiSecret,
		AccountSid: accountSid,
	})

	params := &verify.CreateAccessTokenParams{}
	params.SetIdentity("Identity")
	params.SetFactorType("push")

	resp, err := client.VerifyV2.CreateAccessToken("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
$apiKey = $_ENV["TWILIO_API_KEY"];
$apiSecret = $_ENV["TWILIO_API_SECRET"];
$sid = $_ENV["TWILIO_ACCOUNT_SID"];
$twilio = new Client($apiKey, $apiSecret, $sid);

$access_token = $twilio->verify->v2
    ->services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->accessTokens->create(
        "Identity", // Identity
        "push", // FactorType
    );

print $access_token->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']
account_sid = ENV['TWILIO_ACCOUNT_SID']
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

access_token = @client
               .verify
               .v2
               .services('VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
               .access_tokens
               .create(
                 identity: 'Identity',
                 factor_type: 'push'
               )

puts access_token.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:verify:v2:services:access-tokens:create \
   --service-sid VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --identity Identity \
   --factor-type push
```

```bash
curl -X POST "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens" \
--data-urlencode "Identity=Identity" \
--data-urlencode "FactorType=push" \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
```

```json
{
  "sid": "YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "entity_identity": "ff483d1ff591898a9942916050d2ca3f",
  "factor_type": "push",
  "factor_friendly_name": "John Doe iPhone",
  "ttl": 300,
  "date_created": "2015-07-30T20:00:00Z",
  "token": "eyJ6aXAiOiJERUYiLCJraWQiOiJTQVNfUzNfX19LTVNfdjEiLCJjdHkiOiJ0d2lsaW8tZnBhO3Y9MSIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJkaXIifQ..qjltWfIgQaTwp2De.81Z_6W4kR-hdlAUvJQCbwS8CQ7QAoFRkOvNMoySEj8zEB4BAY3MXhPARfaK4Lnr4YceA2cXEmrzPKQ7bPm0XZMGYm1fqLYzAR8YAqUetI9WEdQLFytg1h4XnJnXhgd99eNXsLkpKHhsCnFkchV9eGpRrdrfB0STR5Xq0fdakomb98iuIFt1XtP0_iqxvxQZKe1O4035XhK_ELVwQBz_qdI77XRZBFM0REAzlnEOe61nOcQxkaIM9Qel9L7RPhcndcCPFAyYjxo6Ri5c4vOnszLDiHmeK9Ep9fRE5-Oz0px0ZEg_FgTUEPFPo2OHQj076H1plJnFr-qPINDJkUL_i7loqG1IlapOi1JSlflPH-Ebj4hhpBdMIcs-OX7jhqzmVqkIKWkpPyPEmfvY2-eA5Zpoo08YpqAJ3G1l_xEcHl28Ijkefj1mdb6E8POx41skAwXCpdfIbzWzV_VjFpmwhacS3JZNt9C4hVG4Yp-RGPEl1C7aJHRIUavAmoRHaXbfG20zzv5Zu0P5PcopDszzoqVfZpzc.GCt35DWTurtP-QaIL5aBSQ",
  "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens/YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Fetch an AccessToken resource

`GET https://verify.twilio.com/v2/Services/{ServiceSid}/AccessTokens/{Sid}`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The unique SID identifier of the Service.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^VA[0-9a-fA-F]{32}$"},"required":true},{"name":"Sid","in":"path","description":"A 34 character string that uniquely identifies this Access Token.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^YK[0-9a-fA-F]{32}$"},"required":true}]
```

Fetch an Access Token for the Entity

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const apiKey = process.env.TWILIO_API_KEY;
const apiSecret = process.env.TWILIO_API_SECRET;
const client = twilio(apiKey, apiSecret, { accountSid: accountSid });

async function fetchAccessToken() {
  const accessToken = await client.verify.v2
    .services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .accessTokens("YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch();

  console.log(accessToken.sid);
}

fetchAccessToken();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = os.environ["TWILIO_API_KEY"]
api_secret = os.environ["TWILIO_API_SECRET"]
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
client = Client(api_key, api_secret, account_sid)

access_token = (
    client.verify.v2.services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .access_tokens("YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .fetch()
)

print(access_token.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Verify.V2.Service;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID at twilio.com/console
        // Provision API Keys at twilio.com/console/runtime/api-keys
        // and set the environment variables. See http://twil.io/secure
        // For local testing, you can use your Account SID and Auth token
        string apiKey = Environment.GetEnvironmentVariable("TWILIO_API_KEY");
        string apiSecret = Environment.GetEnvironmentVariable("TWILIO_API_SECRET");
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");

        TwilioClient.Init(apiKey, apiSecret, accountSid);

        var accessToken = await AccessTokenResource.FetchAsync(
            pathServiceSid: "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathSid: "YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(accessToken.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.verify.v2.service.AccessToken;

public class Example {
    // Find your Account SID at twilio.com/console
    // Provision API Keys at twilio.com/console/runtime/api-keys
    // and set the environment variables. See http://twil.io/secure
    // For local testing, you can use your Account SID and Auth token
    public static final String API_KEY = System.getenv("TWILIO_API_KEY");
    public static final String API_SECRET = System.getenv("TWILIO_API_SECRET");
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");

    public static void main(String[] args) {
        Twilio.init(API_KEY, API_SECRET, ACCOUNT_SID);
        AccessToken accessToken =
            AccessToken.fetcher("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch();

        System.out.println(accessToken.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID at twilio.com/console
	// Provision API Keys at twilio.com/console/runtime/api-keys
	// and set the environment variables. See http://twil.io/secure
	// For local testing, you can use your Account SID and Auth token
	accountSid := os.Getenv("TWILIO_ACCOUNT_SID")
	apiKey := os.Getenv("TWILIO_API_KEY")
	apiSecret := os.Getenv("TWILIO_API_SECRET")
	client := twilio.NewRestClientWithParams(twilio.ClientParams{
		Username:   apiKey,
		Password:   apiSecret,
		AccountSid: accountSid,
	})

	resp, err := client.VerifyV2.FetchAccessToken("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID at twilio.com/console
// Provision API Keys at twilio.com/console/runtime/api-keys
// and set the environment variables. See http://twil.io/secure
// For local testing, you can use your Account SID and Auth token
$apiKey = $_ENV["TWILIO_API_KEY"];
$apiSecret = $_ENV["TWILIO_API_SECRET"];
$sid = $_ENV["TWILIO_ACCOUNT_SID"];
$twilio = new Client($apiKey, $apiSecret, $sid);

$access_token = $twilio->verify->v2
    ->services("VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->accessTokens("YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->fetch();

print $access_token->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID at twilio.com/console
# Provision API Keys at twilio.com/console/runtime/api-keys
# and set the environment variables. See http://twil.io/secure
# For local testing, you can use your Account SID and Auth token
api_key = ENV['TWILIO_API_KEY']
api_secret = ENV['TWILIO_API_SECRET']
account_sid = ENV['TWILIO_ACCOUNT_SID']
@client = Twilio::REST::Client.new(api_key, api_secret, account_sid)

access_token = @client
               .verify
               .v2
               .services('VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
               .access_tokens('YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
               .fetch

puts access_token.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:verify:v2:services:access-tokens:fetch \
   --service-sid VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --sid YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens/YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_API_KEY:$TWILIO_API_SECRET
```

```json
{
  "sid": "YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "entity_identity": "ff483d1ff591898a9942916050d2ca3f",
  "factor_type": "push",
  "factor_friendly_name": "John Doe iPhone",
  "ttl": 60,
  "date_created": "2015-07-30T20:00:00Z",
  "token": "eyJ6aXAiOiJERUYiLCJraWQiOiJTQVNfUzNfX19LTVNfdjEiLCJjdHkiOiJ0d2lsaW8tZnBhO3Y9MSIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJkaXIifQ..qjltWfIgQaTwp2De.81Z_6W4kR-hdlAUvJQCbwS8CQ7QAoFRkOvNMoySEj8zEB4BAY3MXhPARfaK4Lnr4YceA2cXEmrzPKQ7bPm0XZMGYm1fqLYzAR8YAqUetI9WEdQLFytg1h4XnJnXhgd99eNXsLkpKHhsCnFkchV9eGpRrdrfB0STR5Xq0fdakomb98iuIFt1XtP0_iqxvxQZKe1O4035XhK_ELVwQBz_qdI77XRZBFM0REAzlnEOe61nOcQxkaIM9Qel9L7RPhcndcCPFAyYjxo6Ri5c4vOnszLDiHmeK9Ep9fRE5-Oz0px0ZEg_FgTUEPFPo2OHQj076H1plJnFr-qPINDJkUL_i7loqG1IlapOi1JSlflPH-Ebj4hhpBdMIcs-OX7jhqzmVqkIKWkpPyPEmfvY2-eA5Zpoo08YpqAJ3G1l_xEcHl28Ijkefj1mdb6E8POx41skAwXCpdfIbzWzV_VjFpmwhacS3JZNt9C4hVG4Yp-RGPEl1C7aJHRIUavAmoRHaXbfG20zzv5Zu0P5PcopDszzoqVfZpzc.GCt35DWTurtP-QaIL5aBSQ",
  "url": "https://verify.twilio.com/v2/Services/VAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/AccessTokens/YKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```
