Subscriptions: list
Stay organized with collections
Save and categorize content based on your preferences.
Requires authorization
Retrieves a list of subscriptions for the authenticated user and service.
See an example.
Request
HTTP request
GET https://www.googleapis.com/mirror/v1/subscriptions
Authorization
This request requires authorization with the following scope (read more about authentication and authorization).
Scope |
https://www.googleapis.com/auth/glass.timeline |
Request body
Do not supply a request body with this method.
Response
If successful, this method returns a response body with the following structure:
{
"kind": "mirror#subscriptionsList",
"items": [
subscriptions Resource
]
}
Property name |
Value |
Description |
Notes |
kind |
string |
The type of resource. This is always mirror#subscriptionsList . |
|
items[] |
list |
The list of subscriptions. |
|
Examples
Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).
Java
Uses the Java client library.
import com.google.api.services.mirror.Mirror;
import com.google.api.services.mirror.model.Subscription;
import com.google.api.services.mirror.model.SubscriptionsListResponse;
import java.io.IOException;
public class MyClass {
// ...
/**
* Print the notification subscriptions for the current user.
*
* @param service Authorized Mirror service.
*/
public static void printSubscriptions(Mirror service) {
try {
SubscriptionsListResponse subscriptions = service.subscriptions().list().execute();
for (Subscription subscription : subscriptions.getItems()) {
System.out.println("Collection: " + subscription.getCollection());
System.out.println("User token: " + subscription.getUserToken());
System.out.println("Verify token: " + subscription.getVerifyToken());
System.out.println("Callback URL: " + subscription.getCallbackUrl());
if (subscription.getOperation() != null && subscription.getOperation().size() > 0) {
System.out.println("Operation:");
for (String operation : subscription.getOperation()) {
System.out.println(" * " + operation);
}
} else {
System.out.println("Operation: ALL");
}
}
} catch (IOException e) {
System.err.println("An error occurred: " + e);
}
}
// ...
}
.NET
Uses the .NET client library.
using System;
using Google.Apis.Mirror.v1;
using Google.Apis.Mirror.v1.Data;
public class MyClass {
// ...
/// <summary>
/// Print the notification subscriptions for the current user.
/// </summary>
/// <param name='service'>Authorized Mirror service.</param>
public static void PrintSubscriptions(MirrorService service) {
try {
SubscriptionsListResponse subscriptions =
service.Subscriptions.List().Fetch();
foreach (Subscription subscription in subscriptions.Items) {
Console.WriteLine("Collection: " + subscription.Collection);
Console.WriteLine("User token: " + subscription.UserToken);
Console.WriteLine("Verify token: " + subscription.VerifyToken);
Console.WriteLine("Callback URL: " + subscription.CallbackUrl);
if (subscription.Operation != null &&
subscription.Operation.Count > 0) {
Console.WriteLine("Operation:");
foreach (String operation in subscription.Operation) {
Console.WriteLine(" * " + operation);
}
} else {
Console.WriteLine("Operation: ALL");
}
}
} catch (Exception e) {
Console.WriteLine("An error occurred: " + e.Message);
}
}
// ...
}
PHP
Uses the PHP client library.
/**
* Print the notification subscriptions for the current user.
*
* @param Google_MirrorService $service Authorized Mirror service.
*/
function printSubscriptions($service) {
try {
$subscriptions = $service->subscriptions->listSubscriptions();
foreach ($subscriptions->getItems() as $subscription) {
print 'Collection: ' . $subscription->getCollection();
print 'User token: ' . $subscription->getUserToken();
print 'Verify token: ' . $subscription->getVerifyToken();
print 'Callback URL: ' . $subscription->getCallbackUrl();
if ($subscription->getOperation()) {
print 'Operation:';
foreach ($subscription->getOperation() as $operation) {
print ' * ' . $operation;
}
print 'Operation: ALL';
}
}
} catch (Exception $e) {
print 'An error occurred: ' . $e->getMessage();
}
}
Python
Uses the Python client library.
from apiclient import errors
# ...
def print_subscriptions(service):
"""Print the notification subscriptions for the current user.
Args:
service: Authorized Mirror service.
"""
try:
subscriptions = service.subscriptions().list().execute()
for subscription in subscriptions.get('items', []):
print 'Collection: %s' % subscription.get('collection')
print 'User token: %s' % subscription.get('userToken')
print 'Verify token: %s' % subscription.get('verifyToken')
print 'Callback URL: %s' % subscription.get('callbackUrl')
if subscription.get('operation'):
print 'Operation:'
for operation in subscription['operation']:
print ' * %s' % operation
else:
print 'Operation: ALL'
except errors.HttpError, e:
print 'An error occurred: %s' % e
Ruby
Uses the Ruby client library.
##
# Print the notification subscriptions for the current user.
#
# @param [Google::APIClient] client
# Authorized client instance.
# @return nil
def print_subscriptions(client)
mirror = client.discovered_api('mirror', 'v1')
result = client.execute(:api_method => mirror.subscriptions.list)
if result.success?
subscriptions = result.data
subscriptions.items.each do |subscription|
puts "Collection: #{subscription.collection}"
puts "User token: #{subscription.user_token}"
puts "Verify token: #{subscription.verify_token}"
puts "Callback URL: #{subscription.callback_url}"
if !subscription.operation.empty?
puts "Operation:"
subscription.operation.each do |operation|
puts " * #{operation}"
end
else
puts "Operation: ALL"
end
end
else
puts "An error occurred: #{result.data['error']['message']}"
end
end
Go
Uses the Go client library.
import (
"code.google.com/p/google-api-go-client/mirror/v1"
"fmt"
)
// PrintSubscriptions prints the notification subscriptions for the current
// user.
func PrintSubscriptions(g *mirror.Service) error {
sl, err := g.Subscriptions.List().Do()
if err != nil {
fmt.Printf("An error occurred: %v\n", err)
return err
}
for _, s := range sl.Items {
fmt.Printf("Collection: %s\n", s.Collection)
fmt.Printf("User token: %s\n", s.UserToken)
fmt.Printf("Verify token: %s\n", s.VerifyToken)
fmt.Printf("Callback URL: %s\n", s.CallbackUrl)
if len(s.Operation) > 0 {
fmt.Printf("Operation:")
for _, o := range s.Operation {
fmt.Printf(" * %s\n", o)
}
} else {
fmt.Printf("Operation: ALL")
}
}
return nil
}
Raw HTTP
Does not use a client library.
GET /mirror/v1/subscriptions HTTP/1.1
Authorization: Bearer auth token
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003eRetrieves a list of subscriptions for the authenticated user, providing details like collection, user token, verification token, callback URL, and operations.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization with the \u003ccode\u003ehttps://www.googleapis.com/auth/glass.timeline\u003c/code\u003e scope.\u003c/p\u003e\n"],["\u003cp\u003eReturns a response containing a list of subscription resources, each detailing a specific subscription.\u003c/p\u003e\n"],["\u003cp\u003eProvides code examples in Java, .NET, PHP, Python, Ruby, and Go for retrieving and handling subscription data.\u003c/p\u003e\n"]]],[],null,["# Subscriptions: list\n\n**Requires [authorization](#auth)**\n\nRetrieves a list of subscriptions for the authenticated user and service.\n[See an example](#examples).\n\nRequest\n-------\n\n### HTTP request\n\n```\nGET https://www.googleapis.com/mirror/v1/subscriptions\n```\n\n### Authorization\n\nThis request requires authorization with the following scope ([read more about authentication and authorization](/glass/authorization)).\n\n| Scope |\n|--------------------------------------------------|\n| `https://www.googleapis.com/auth/glass.timeline` |\n\n### Request body\n\nDo not supply a request body with this method.\n\nResponse\n--------\n\nIf successful, this method returns a response body with the following structure:\n\n```objective-c\n{\n \"kind\": \"mirror#subscriptionsList\",\n \"items\": [\n subscriptions Resource\n ]\n}\n```\n\n| Property name | Value | Description | Notes |\n|---------------|----------|------------------------------------------------------------------|-------|\n| `kind` | `string` | The type of resource. This is always `mirror#subscriptionsList`. | |\n| `items[]` | `list` | The list of subscriptions. | |\n\nExamples\n--------\n\n**Note:** The code examples available for this method do not represent all supported programming languages (see the [client libraries page](/glass/tools-downloads/client-libraries) for a list of supported languages). \n\n### Java\n\nUses the [Java client library](/glass/tools-downloads/client-libraries). \n\n```java\nimport com.google.api.services.mirror.Mirror;\nimport com.google.api.services.mirror.model.Subscription;\nimport com.google.api.services.mirror.model.SubscriptionsListResponse;\n\nimport java.io.IOException;\n\npublic class MyClass {\n // ...\n\n /**\n * Print the notification subscriptions for the current user.\n * \n * @param service Authorized Mirror service.\n */\n public static void printSubscriptions(Mirror service) {\n try {\n SubscriptionsListResponse subscriptions = service.subscriptions().list().execute();\n\n for (Subscription subscription : subscriptions.getItems()) {\n System.out.println(\"Collection: \" + subscription.getCollection());\n System.out.println(\"User token: \" + subscription.getUserToken());\n System.out.println(\"Verify token: \" + subscription.getVerifyToken());\n System.out.println(\"Callback URL: \" + subscription.getCallbackUrl());\n\n if (subscription.getOperation() != null && subscription.getOperation().size() \u003e 0) {\n System.out.println(\"Operation:\");\n for (String operation : subscription.getOperation()) {\n System.out.println(\" * \" + operation);\n }\n } else {\n System.out.println(\"Operation: ALL\");\n }\n }\n } catch (IOException e) {\n System.err.println(\"An error occurred: \" + e);\n }\n }\n \n // ...\n}\n```\n\n### .NET\n\nUses the [.NET client library](/glass/tools-downloads/client-libraries). \n\n```css+lasso\nusing System;\n\nusing Google.Apis.Mirror.v1;\nusing Google.Apis.Mirror.v1.Data;\n\npublic class MyClass {\n // ...\n\n /// \u003csummary\u003e\n /// Print the notification subscriptions for the current user.\n /// \u003c/summary\u003e\n /// \u003cparam name='service'\u003eAuthorized Mirror service.\u003c/param\u003e\n public static void PrintSubscriptions(MirrorService service) {\n try {\n SubscriptionsListResponse subscriptions =\n service.Subscriptions.List().Fetch();\n\n foreach (Subscription subscription in subscriptions.Items) {\n Console.WriteLine(\"Collection: \" + subscription.Collection);\n Console.WriteLine(\"User token: \" + subscription.UserToken);\n Console.WriteLine(\"Verify token: \" + subscription.VerifyToken);\n Console.WriteLine(\"Callback URL: \" + subscription.CallbackUrl);\n\n if (subscription.Operation != null &&\n subscription.Operation.Count \u003e 0) {\n Console.WriteLine(\"Operation:\");\n foreach (String operation in subscription.Operation) {\n Console.WriteLine(\" * \" + operation);\n }\n } else {\n Console.WriteLine(\"Operation: ALL\");\n }\n }\n } catch (Exception e) {\n Console.WriteLine(\"An error occurred: \" + e.Message);\n }\n }\n\n // ...\n}\n```\n\n### PHP\n\nUses the [PHP client library](/glass/tools-downloads/client-libraries). \n\n```php\n/**\n * Print the notification subscriptions for the current user.\n *\n * @param Google_MirrorService $service Authorized Mirror service.\n */\nfunction printSubscriptions($service) {\n try {\n $subscriptions = $service-\u003esubscriptions-\u003elistSubscriptions();\n\n foreach ($subscriptions-\u003egetItems() as $subscription) {\n print 'Collection: ' . $subscription-\u003egetCollection();\n print 'User token: ' . $subscription-\u003egetUserToken();\n print 'Verify token: ' . $subscription-\u003egetVerifyToken();\n print 'Callback URL: ' . $subscription-\u003egetCallbackUrl();\n\n if ($subscription-\u003egetOperation()) {\n print 'Operation:';\n foreach ($subscription-\u003egetOperation() as $operation) {\n print ' * ' . $operation;\n }\n print 'Operation: ALL';\n }\n }\n } catch (Exception $e) {\n print 'An error occurred: ' . $e-\u003egetMessage();\n }\n}\n```\n\n### Python\n\nUses the [Python client library](/glass/tools-downloads/client-libraries). \n\n```python\nfrom apiclient import errors\n# ...\n\ndef print_subscriptions(service):\n \"\"\"Print the notification subscriptions for the current user.\n\n Args:\n service: Authorized Mirror service.\n \"\"\"\n try:\n subscriptions = service.subscriptions().list().execute()\n\n for subscription in subscriptions.get('items', []):\n print 'Collection: %s' % subscription.get('collection')\n print 'User token: %s' % subscription.get('userToken')\n print 'Verify token: %s' % subscription.get('verifyToken')\n print 'Callback URL: %s' % subscription.get('callbackUrl')\n\n if subscription.get('operation'):\n print 'Operation:'\n for operation in subscription['operation']:\n print ' * %s' % operation\n else:\n print 'Operation: ALL'\n except errors.HttpError, e:\n print 'An error occurred: %s' % e\n```\n\n### Ruby\n\nUses the [Ruby client library](/glass/tools-downloads/client-libraries). \n\n```ruby\n##\n# Print the notification subscriptions for the current user.\n#\n# @param [Google::APIClient] client\n# Authorized client instance.\n# @return nil\ndef print_subscriptions(client)\n mirror = client.discovered_api('mirror', 'v1')\n result = client.execute(:api_method =\u003e mirror.subscriptions.list)\n if result.success?\n subscriptions = result.data\n subscriptions.items.each do |subscription|\n puts \"Collection: #{subscription.collection}\"\n puts \"User token: #{subscription.user_token}\"\n puts \"Verify token: #{subscription.verify_token}\"\n puts \"Callback URL: #{subscription.callback_url}\"\n\n if !subscription.operation.empty?\n puts \"Operation:\"\n subscription.operation.each do |operation|\n puts \" * #{operation}\"\n end\n else\n puts \"Operation: ALL\"\n end\n end\n else\n puts \"An error occurred: #{result.data['error']['message']}\"\n end\nend\n```\n\n### Go\n\nUses the [Go client library](/glass/tools-downloads/client-libraries). \n\n```go\nimport (\n\t\"code.google.com/p/google-api-go-client/mirror/v1\"\n\t\"fmt\"\n)\n\n// PrintSubscriptions prints the notification subscriptions for the current\n// user.\nfunc PrintSubscriptions(g *mirror.Service) error {\n\tsl, err := g.Subscriptions.List().Do()\n\tif err != nil {\n\t\tfmt.Printf(\"An error occurred: %v\\n\", err)\n\t\treturn err\n\t}\n\tfor _, s := range sl.Items {\n\t\tfmt.Printf(\"Collection: %s\\n\", s.Collection)\n\t\tfmt.Printf(\"User token: %s\\n\", s.UserToken)\n\t\tfmt.Printf(\"Verify token: %s\\n\", s.VerifyToken)\n\t\tfmt.Printf(\"Callback URL: %s\\n\", s.CallbackUrl)\n\n\t\tif len(s.Operation) \u003e 0 {\n\t\t\tfmt.Printf(\"Operation:\")\n\t\t\tfor _, o := range s.Operation {\n\t\t\t\tfmt.Printf(\" * %s\\n\", o)\n\t\t\t}\n\t\t} else {\n\t\t\tfmt.Printf(\"Operation: ALL\")\n\t\t}\n\t}\n\treturn nil\n}\n```\n\n### Raw HTTP\n\nDoes not use a client library. \n\n```http\nGET /mirror/v1/subscriptions HTTP/1.1\nAuthorization: Bearer auth token\n```"]]