<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Service Account Roles to Access SDM Services/APIs in Smart Home Developer Forum</title>
    <link>https://www.googlenestcommunity.com/t5/Smart-Home-Developer-Forum/Service-Account-Roles-to-Access-SDM-Services-APIs/m-p/475093#M1207</link>
    <description>&lt;P&gt;Can you please clarify if the Authorization Field in the print access token section should contain the char "f" before the bearer ?Also, can you share the&amp;nbsp;&lt;SPAN&gt;http protocol request (header and data payload) ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;These information will help us in debugging the issue faster.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Aug 2023 16:31:56 GMT</pubDate>
    <dc:creator>sipriyadarshi</dc:creator>
    <dc:date>2023-08-30T16:31:56Z</dc:date>
    <item>
      <title>Service Account Roles to Access SDM Services/APIs</title>
      <link>https://www.googlenestcommunity.com/t5/Smart-Home-Developer-Forum/Service-Account-Roles-to-Access-SDM-Services-APIs/m-p/473494#M1192</link>
      <description>&lt;P&gt;I am writing a Python script to access my nest thermostat.&amp;nbsp; I am able to generate&amp;nbsp; a token this way:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;def&lt;/SPAN&gt; &lt;SPAN&gt;get_access_token&lt;/SPAN&gt;&lt;SPAN&gt;():&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;global&lt;/SPAN&gt; &lt;SPAN&gt;ACCESS_TOKEN&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;HEADERS&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# Path to the service account JSON key file&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;service_account_key_path&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;./weatherflow-pi-project-sa.json&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;# Define the scopes for which you need an access token&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;scopes&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;[&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;&lt;A href="https://www.googleapis.com/auth/sdm.service" target="_blank"&gt;https://www.googleapis.com/auth/sdm.service&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;# Load the service account credentials&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;credentials&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; service_account&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Credentials&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;from_service_account_file&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;service_account_key_path&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;scopes&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;scopes&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;# Obtain an access token&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;credentials&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;refresh&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Request&lt;/SPAN&gt;&lt;SPAN&gt;())&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;# Print the access token&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Access Token:&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;credentials&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;token&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;ACCESS_TOKEN&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;credentials&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;token&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;HEADERS&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;Content-Type&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;application/json&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;Authorization&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;f&lt;/SPAN&gt;&lt;SPAN&gt;"Bearer &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;ACCESS_TOKEN&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;}&lt;BR /&gt;&lt;BR /&gt;However when I go to fetch devices via&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;SPAN&gt;response&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;requests&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;get&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;google_oauth&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;API_URL&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;headers&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;google_oauth&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;HEADERS&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;)&lt;BR /&gt;The API_URL is&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;A href="https://smartdevicemanagement.googleapis.com/v1/enterprises/" target="_blank"&gt;https://smartdevicemanagement.googleapis.com/v1/enterprises/&lt;/A&gt;&lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;PROJECT_ID&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;SPAN&gt;/devices&lt;BR /&gt;I get a 404 not found.&amp;nbsp; This worked before when I was using a user based token and not a service account&lt;BR /&gt;&lt;BR /&gt;I believe the problem is I need to add a role/permission to the service account to have access to my project.&amp;nbsp; Any clue on the correct role ?&lt;BR /&gt;thanks&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 26 Aug 2023 00:06:33 GMT</pubDate>
      <guid>https://www.googlenestcommunity.com/t5/Smart-Home-Developer-Forum/Service-Account-Roles-to-Access-SDM-Services-APIs/m-p/473494#M1192</guid>
      <dc:creator>jjkirby</dc:creator>
      <dc:date>2023-08-26T00:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: Service Account Roles to Access SDM Services/APIs</title>
      <link>https://www.googlenestcommunity.com/t5/Smart-Home-Developer-Forum/Service-Account-Roles-to-Access-SDM-Services-APIs/m-p/475093#M1207</link>
      <description>&lt;P&gt;Can you please clarify if the Authorization Field in the print access token section should contain the char "f" before the bearer ?Also, can you share the&amp;nbsp;&lt;SPAN&gt;http protocol request (header and data payload) ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;These information will help us in debugging the issue faster.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Aug 2023 16:31:56 GMT</pubDate>
      <guid>https://www.googlenestcommunity.com/t5/Smart-Home-Developer-Forum/Service-Account-Roles-to-Access-SDM-Services-APIs/m-p/475093#M1207</guid>
      <dc:creator>sipriyadarshi</dc:creator>
      <dc:date>2023-08-30T16:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: Service Account Roles to Access SDM Services/APIs</title>
      <link>https://www.googlenestcommunity.com/t5/Smart-Home-Developer-Forum/Service-Account-Roles-to-Access-SDM-Services-APIs/m-p/475103#M1208</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;Also called “formatted string literals,” f-strings are string literals that have an&amp;nbsp;"f" at the beginning and curly braces containing expressions that will be replaced with their values.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;It's a GET so no payload&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Below is a print stament of the headers being passed just before the call:&lt;BR /&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT color="#339966"&gt;&lt;SPAN&gt;response&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;requests&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;get&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;google_oauth&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;API_URL&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN&gt;headers&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;google_oauth&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;HEADERS&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;HEADERS: {'Content-Type': 'application/json', 'Authorization': 'Bearer ya29.c.b0Aaekm1KUJ5bq1z-CjZSJQQ2kz-cyHi_8grlfXjhuqHVA7k7fDRs1ptyOI1mKbCOi32IXaW9agQf5PtnjmONvjJEhwcRxxarhEBjdM3oXd4BgrmpcDR-saPOBFC7URhDptnRqOzxNem6nu0SjxPah2QNQP2T92k4OaLFzEj0_NQ4L6A7wH9EyRwPqRxD5dd84x9qmsLFzx6PRZ1lRr1wgectJfiJFHVCJkFy6iZtzNPgFcQjbQdHbFVbccBDifNWRhBmcMmealDZS-z0KJiVdkKidBWNNjynzmfI19jqYvMnq9LNxcX243eVXrfc5fZfUgoMactUVXAL339Cr8wqxRtqUFomUOgpkuiQ8I912mi6vmJBoiMvU1tY_-MupYkvOS6cQbrofz9yroFSeMI78oafJJe_jzW0IqreXfrRW87oIrMMfIFUaUSY0hVqnopYJthgyX1UrRgIa9yhZne7qddBa3xWkIJR_tFqZM5oIY7cy5RYBvU-3aWf0wciWr4akebze2WI9MXXRJxmtUOQnxfBF2vW-vwFm_3p8XJlJn6YpF31ipivwV-z0i9Oix-cIwJoW65z13zfo32iYrhu_MpWZn0QYyQeSdxM1IFc-OwtvbVFm3jYvj5kQjBn-cQJ29fUkwYrVOsUVOewj0XazR9_F8orUshOBIO3pY4bvmnsta2IQrZW7IvMw-346I8u2rt4oby_td-0mJaveSdFcc3-UnMZxoJqvRQZv0BvyXqkqfgSjkwkQOFkf-_5ZjYb77Yjie_9Ic9zVI82ar_71Ir2nd5oe2adZ3xSgI2oJ18i345JpyIfqsipJg0_07UUI1au47Vn2zw2OS5pU4VzzV7MW5fkBplBzx_YBSXetBQvmQX_rRbUg4qdO7YBu37rmqVoW4Wg0833OwuOXo2cp1edyeiwBJn1e0kOrZoO9y-Z1_sYcJYq3jUQcrlyoZYrkgd1kbiUSserjwwVVi8sS83V7l_w2avXvWb9rJ1SVvfR-'}&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 30 Aug 2023 17:25:08 GMT</pubDate>
      <guid>https://www.googlenestcommunity.com/t5/Smart-Home-Developer-Forum/Service-Account-Roles-to-Access-SDM-Services-APIs/m-p/475103#M1208</guid>
      <dc:creator>jjkirby</dc:creator>
      <dc:date>2023-08-30T17:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Service Account Roles to Access SDM Services/APIs</title>
      <link>https://www.googlenestcommunity.com/t5/Smart-Home-Developer-Forum/Service-Account-Roles-to-Access-SDM-Services-APIs/m-p/475104#M1209</link>
      <description>&lt;P&gt;So my real question is what roles should I assign to the service account so it has access to the project?&lt;BR /&gt;I am using:&lt;/P&gt;&lt;DIV class=""&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN class=""&gt;Owner&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;Service Account Token Creator&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I assume if the request was not authorized I could get a 404 return code.&amp;nbsp; I have had this working with a user based generated token.&amp;nbsp; I am moving to a service account becuase this is going into a Raspberry PI making continuous interval GETS on Nest Temperature.&amp;nbsp; Refresh Tokens have a shelf life and will eventually expire.&amp;nbsp; So that is why I am using a service account&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 30 Aug 2023 17:29:25 GMT</pubDate>
      <guid>https://www.googlenestcommunity.com/t5/Smart-Home-Developer-Forum/Service-Account-Roles-to-Access-SDM-Services-APIs/m-p/475104#M1209</guid>
      <dc:creator>jjkirby</dc:creator>
      <dc:date>2023-08-30T17:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Service Account Roles to Access SDM Services/APIs</title>
      <link>https://www.googlenestcommunity.com/t5/Smart-Home-Developer-Forum/Service-Account-Roles-to-Access-SDM-Services-APIs/m-p/739726#M9560</link>
      <description>&lt;P&gt;It sounds like the 404 issue is happening because the service account doesn’t have the right permissions assigned to access the Smart Device Management API. You may need to review the roles available in your Google Cloud project and grant the service account access to SDM resources, since without the correct roles it won’t be able to fetch devices. It’s a bit like hiring wall painting services&amp;nbsp; if the painters don’t have the right tools or materials, the job won’t be done properly. Once the right permissions are added, your script should start working as expected.&lt;/P&gt;</description>
      <pubDate>Sat, 30 Aug 2025 06:26:04 GMT</pubDate>
      <guid>https://www.googlenestcommunity.com/t5/Smart-Home-Developer-Forum/Service-Account-Roles-to-Access-SDM-Services-APIs/m-p/739726#M9560</guid>
      <dc:creator>ikpainting1122</dc:creator>
      <dc:date>2025-08-30T06:26:04Z</dc:date>
    </item>
  </channel>
</rss>

