{"id":4722,"date":"2013-01-07T04:18:06","date_gmt":"2013-01-07T04:18:06","guid":{"rendered":"http:\/\/zerokidz.com\/ideas\/?p=4722"},"modified":"2014-06-18T04:03:21","modified_gmt":"2014-06-18T08:03:21","slug":"google-oauth-2-0-authorization-for-devices","status":"publish","type":"post","link":"https:\/\/reactivemusic.net\/?p=4722","title":{"rendered":"Google oauth 2.0 authorization for devices"},"content":{"rendered":"<p><strong style=\"line-height: 1.6;\">What this means<\/strong><span style=\"line-height: 1.6;\">: You create an app on a device which doesn&#8217;t have a browser. For example, an Arduino, an appliance, or a game console.\u00a0This procedure shows how to authorize that device to access a user&#8217;s account for Google, Twitter, Facebook, etc.,<\/span><\/p>\n<p>See this URL for Google instructions:\u00a0<a href=\"See this URL for instructions: https:\/\/developers.google.com\/accounts\/docs\/OAuth2ForDevices\">https:\/\/developers.google.com\/accounts\/docs\/OAuth2ForDevices<\/a><\/p>\n<p>Notes and Google examples (using curl from a command line):<\/p>\n<p>Here is an oauth 2.0 google request for a user code &#8211; The client id is obtained using instructions found at the link above.<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">curl -d &quot;client_id=104588205543369.apps.googleusercontent.com&amp;scope=https:\/\/www.googleapis.com\/auth\/userinfo.email  https:\/\/www.googleapis.com\/auth\/userinfo.profile&quot; https:\/\/accounts.google.com\/o\/oauth2\/device\/code<\/pre>\n<p>Which returned this JSON response:<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">{\r\n  &quot;device_code&quot; : &quot;4\/Gujc7GxpGFSHNlphxVZCK_y10yS6Kq&quot;,\r\n  &quot;user_code&quot; : &quot;ibaz70ej9&quot;,\r\n  &quot;verification_url&quot; : &quot;http:\/\/www.google.com\/device&quot;,\r\n  &quot;expires_in&quot; : 1800,\r\n  &quot;interval&quot; : 5\r\n}<\/pre>\n<p>Then you go to the URL in the response, enter the user code, and follow instructions&#8230;<\/p>\n<p>Then from the device you do this&#8230;<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">curl -d &quot;client_id=1045882053369.apps.googleusercontent.com&amp;client_secret=zDP5UVwbqcYzv7rnVieKxnOV&amp;code=4\/Gujc7GxpGHNlphxVZCK_y10yS6Kq&amp;grant_type=http:\/\/oauth.net\/grant_type\/device\/1.0&quot; https:\/\/accounts.google.com\/o\/oauth2\/token<\/pre>\n<p>Which returns this response:<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">{\r\n  &quot;access_token&quot; : &quot;ya29.AHES6ZE2QxqzZyWkGu20lJljEIHYTf08VtggyRF73428w0LQ7lzFP_uw&quot;,\r\n  &quot;token_type&quot; : &quot;Bearer&quot;,\r\n  &quot;expires_in&quot; : 3600,\r\n  &quot;id_token&quot; : &quot;eyJhbGciOiJSUzI1NiIsImtpZCI6ImJhZGQ4NWFhMmRlZmZkMWFkZWJkNzc2NTgxNWMzZmVjZTM0MmIzNGEifQ.eyJpc3MiOiJhY2NvdW50cy5nb29nbGUuY29tIiwiaWQiOiIxMTExNzg0MjgyNzI3MDgxMTI0NTMiLCJhdWQiOiIxMDQ1ODgyMDUzMzY5LmFwcHMuZ2df9vZ2xldXNlcmNvbnRlbnQuY29tIiwiY2lkIjoiMTA0NTg4MjA1MzM2OS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsInZlcmlmaWVkX2VtYWlsIjoidHJ1ZSIsInRva2VuX2hhc2gefiOiJvVG9OdS0tYU1DUGhYbUI1S3p4TTN3IiwiZW1haWwiOiJ6aWNhcmVsdEBnb3VsZGFjYWRlbXkub3JnIiwiaGQiOiJnb3VsZGFjYWRlbXkub3JnIiwiaWF0IjoxMzU2MjQ2Mjg2LCJleHAiOjEzNTYyNTAxODZ9.DqIqLtg9m6wlHh5YSFFgXIOgbMW0E2mKR2FdY7PWtNJrt91moqVBe7dQxQPNalQMKhYTapJdVk2MB1oRl7zXEnLIe_VjI3BUwzTKqaG_sS9oRyh14_yqDWeMFru5d7OFUm1Ulwb2lLdWWwtttEVyJiw94oBdR0tuWg0MNkEOkXU&quot;,\r\n  &quot;refresh_token&quot; : &quot;1\/NuEmigydABgeRwZaRCZbZZckJ-EJFZd8C1YZLURut8s&quot;\r\n}<\/pre>\n<p>Now your device can use the access token\u00a0query string method&#8230;<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">curl https:\/\/www.googleapis.com\/oauth2\/v1\/userinfo?access_token=ya29.AHES6ZQxqzZyWkGu20lJljEIHYTf08VtggyRF73428w0LQ7lzFP_uw<\/pre>\n<p>Here is the response:<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">{\r\n &quot;id&quot;: &quot;1111784282727081812453&quot;,\r\n &quot;email&quot;: &quot;looney@looney.org&quot;,\r\n &quot;verified_email&quot;: true,\r\n &quot;name&quot;: &quot;Tony Tiger&quot;,\r\n &quot;given_name&quot;: &quot;Tony&quot;,\r\n &quot;family_name&quot;: &quot;Tiger&quot;,\r\n &quot;hd&quot;: &quot;looney.org&quot;\r\n}<\/pre>\n<p>Or you can use the http header option&#8230;<\/p>\n<pre class=\"brush: actionscript3; gutter: true\">curl -H &quot;Authorization: Bearer ya29.AHKKES6ZQxqzZyWkGu20lJljEIHYTf08VtggyRF73428w0LQ7lzFP_uw&quot; https:\/\/www.googleapis.com\/oauth2\/v1\/user info<\/pre>\n<p>which should return the exact same response.<\/p>\n<p>[Also see] tkzic\/max teaching examples\/google-oauth2.0-readme.txt<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What this means: You create an app on a device which doesn&#8217;t have a browser. For example, an Arduino, an appliance, or a game console.\u00a0This procedure shows how to authorize that device to access a user&#8217;s account for Google, Twitter, Facebook, etc., See this URL for Google instructions:\u00a0https:\/\/developers.google.com\/accounts\/docs\/OAuth2ForDevices Notes and Google examples (using curl from &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/reactivemusic.net\/?p=4722\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Google oauth 2.0 authorization for devices&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[143],"tags":[161,179,90,6,18,190,25,12],"class_list":["post-4722","post","type-post","status-publish","format-standard","hentry","category-interactive-media-art","tag-api","tag-google","tag-how-to","tag-interactive-media","tag-mashup","tag-portfolio","tag-programming","tag-web-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Google oauth 2.0 authorization for devices - reactive music<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/reactivemusic.net\/?p=4722\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Google oauth 2.0 authorization for devices - reactive music\" \/>\n<meta property=\"og:description\" content=\"What this means: You create an app on a device which doesn&#8217;t have a browser. For example, an Arduino, an appliance, or a game console.\u00a0This procedure shows how to authorize that device to access a user&#8217;s account for Google, Twitter, Facebook, etc., See this URL for Google instructions:\u00a0https:\/\/developers.google.com\/accounts\/docs\/OAuth2ForDevices Notes and Google examples (using curl from &hellip; Continue reading &quot;Google oauth 2.0 authorization for devices&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/reactivemusic.net\/?p=4722\" \/>\n<meta property=\"og:site_name\" content=\"reactive music\" \/>\n<meta property=\"article:published_time\" content=\"2013-01-07T04:18:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-06-18T08:03:21+00:00\" \/>\n<meta name=\"author\" content=\"Tom Zicarelli\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tom Zicarelli\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4722#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4722\"},\"author\":{\"name\":\"Tom Zicarelli\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\"},\"headline\":\"Google oauth 2.0 authorization for devices\",\"datePublished\":\"2013-01-07T04:18:06+00:00\",\"dateModified\":\"2014-06-18T08:03:21+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4722\"},\"wordCount\":171,\"keywords\":[\"API\",\"Google\",\"how to\",\"interactive media\",\"mashup\",\"portfolio\",\"programming\",\"web development\"],\"articleSection\":[\"interactive media art\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4722\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4722\",\"name\":\"Google oauth 2.0 authorization for devices - reactive music\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#website\"},\"datePublished\":\"2013-01-07T04:18:06+00:00\",\"dateModified\":\"2014-06-18T08:03:21+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4722#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/reactivemusic.net\\\/?p=4722\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/?p=4722#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/reactivemusic.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Google oauth 2.0 authorization for devices\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#website\",\"url\":\"https:\\\/\\\/reactivemusic.net\\\/\",\"name\":\"reactive music\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/reactivemusic.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/reactivemusic.net\\\/#\\\/schema\\\/person\\\/56224d281582df7e5518e037ca63e571\",\"name\":\"Tom Zicarelli\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g\",\"caption\":\"Tom Zicarelli\"},\"sameAs\":[\"http:\\\/\\\/tomzicarelli.com\"],\"url\":\"https:\\\/\\\/reactivemusic.net\\\/?author=2\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Google oauth 2.0 authorization for devices - reactive music","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/reactivemusic.net\/?p=4722","og_locale":"en_US","og_type":"article","og_title":"Google oauth 2.0 authorization for devices - reactive music","og_description":"What this means: You create an app on a device which doesn&#8217;t have a browser. For example, an Arduino, an appliance, or a game console.\u00a0This procedure shows how to authorize that device to access a user&#8217;s account for Google, Twitter, Facebook, etc., See this URL for Google instructions:\u00a0https:\/\/developers.google.com\/accounts\/docs\/OAuth2ForDevices Notes and Google examples (using curl from &hellip; Continue reading \"Google oauth 2.0 authorization for devices\"","og_url":"https:\/\/reactivemusic.net\/?p=4722","og_site_name":"reactive music","article_published_time":"2013-01-07T04:18:06+00:00","article_modified_time":"2014-06-18T08:03:21+00:00","author":"Tom Zicarelli","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Tom Zicarelli","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/reactivemusic.net\/?p=4722#article","isPartOf":{"@id":"https:\/\/reactivemusic.net\/?p=4722"},"author":{"name":"Tom Zicarelli","@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571"},"headline":"Google oauth 2.0 authorization for devices","datePublished":"2013-01-07T04:18:06+00:00","dateModified":"2014-06-18T08:03:21+00:00","mainEntityOfPage":{"@id":"https:\/\/reactivemusic.net\/?p=4722"},"wordCount":171,"keywords":["API","Google","how to","interactive media","mashup","portfolio","programming","web development"],"articleSection":["interactive media art"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/reactivemusic.net\/?p=4722","url":"https:\/\/reactivemusic.net\/?p=4722","name":"Google oauth 2.0 authorization for devices - reactive music","isPartOf":{"@id":"https:\/\/reactivemusic.net\/#website"},"datePublished":"2013-01-07T04:18:06+00:00","dateModified":"2014-06-18T08:03:21+00:00","author":{"@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571"},"breadcrumb":{"@id":"https:\/\/reactivemusic.net\/?p=4722#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/reactivemusic.net\/?p=4722"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/reactivemusic.net\/?p=4722#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/reactivemusic.net\/"},{"@type":"ListItem","position":2,"name":"Google oauth 2.0 authorization for devices"}]},{"@type":"WebSite","@id":"https:\/\/reactivemusic.net\/#website","url":"https:\/\/reactivemusic.net\/","name":"reactive music","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/reactivemusic.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/reactivemusic.net\/#\/schema\/person\/56224d281582df7e5518e037ca63e571","name":"Tom Zicarelli","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0da58cf21a2707dd335b204b8ed3cd9194dcbf9d9814ac5d71195a65c76c8a72?s=96&d=mm&r=g","caption":"Tom Zicarelli"},"sameAs":["http:\/\/tomzicarelli.com"],"url":"https:\/\/reactivemusic.net\/?author=2"}]}},"_links":{"self":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/4722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4722"}],"version-history":[{"count":10,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/4722\/revisions"}],"predecessor-version":[{"id":15260,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=\/wp\/v2\/posts\/4722\/revisions\/15260"}],"wp:attachment":[{"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/reactivemusic.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}