<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to get Google contacts from an app using FusionAuth]]></title><description><![CDATA[<p dir="auto">Hi, I'm writing an article on getting a user's Google contacts in a web app, via FusionAuth (FA), based on these two conversations:</p>
<ul>
<li><a href="https://fusionauth.io/community/forum/topic/2659/access-google-calendars-of-multiple-google-accounts-with-user-permission/2">https://fusionauth.io/community/forum/topic/2659/access-google-calendars-of-multiple-google-accounts-with-user-permission/2</a></li>
<li><a href="https://fusionauth.io/community/forum/topic/2569/how-do-i-call-a-google-api-or-retrieve-the-google-credentials">https://fusionauth.io/community/forum/topic/2569/how-do-i-call-a-google-api-or-retrieve-the-google-credentials</a></li>
</ul>
<p dir="auto"><em>"The brief says "that button uses the identity provider login OIDC API to complete the login. That is, the dev starts the OIDC process but FA completes it and holds the token. After the user connects Google, the application then calls into FA to get the refresh token. Then it can call the Google API to get the contacts"</em></p>
<p dir="auto">There are some parts I'm confused about. Please clarify the best approach if you can:</p>
<ol>
<li>I assume the user logs in to the app with FA with a username like <a href="mailto:richard@example.com" rel="nofollow ugc">richard@example.com</a>, but connects to Google with an email like <a href="mailto:richard@gmail.com" rel="nofollow ugc">richard@gmail.com</a>. So the user is <em>not</em> logging in to FA with Google at first. If I'm wrong, please let me know.</li>
<li>What benefit does the app getting Google contacts with FA have? Why shouldn't the app call Google directly through their API, or with custom code?</li>
<li>I assume the app will log the user in to Google by calling <a href="https://fusionauth.io/docs/apis/identity-providers/openid-connect#complete-an-openid-connect-login" rel="nofollow ugc">https://fusionauth.io/docs/apis/identity-providers/openid-connect#complete-an-openid-connect-login</a>, with a linking strategy in the OpenId provider created in settings of "Pending Link". The Response of this API is a User object. But shouldn't it return a Google token? How do we use a User object to call Google here? Also, this doesn't seem like the app "starting" the OIDC process, it seems like FA does all of it. Have I picked the wrong API call?  How do we link the current FA user to their Google email?</li>
<li>As I understand Google sign in, you have to use a snippet of Google JS in your app, which shows a UI form to the user. Which you can't do if calling an API programmatically only. What am I misunderstanding here?</li>
<li>"calls into FA to get the refresh token" - Which API allows this, and what parameters should be passed in?</li>
</ol>
<p dir="auto">Thanks.</p>
<p dir="auto">PS. I wanted to my improve my knowledge of OAuth significantly for this article, but the "form" on this page to get your ebooks is just a grey line I can't interact with - <a href="https://fusionauth.io/ebooks/modern-guide-to-oauth" rel="nofollow ugc">https://fusionauth.io/ebooks/modern-guide-to-oauth</a></p>
<hr />
<p dir="auto">UPDATE WHILE WAITING FOR FORUM APPROVAL:</p>
<ul>
<li>I added an href in my app pointing to <code>https://accounts.google.com/o/oauth2/v2/auth?client_id=535042435541-eridnie9d09pa69dsq1hh066ushvp4e0.apps.googleusercontent.com&amp;redirect_uri=http://localhost:9011/api/identity-provider/login&amp;response_type=code&amp;scope=openid%20email%20profile%20https://www.googleapis.com/auth/contacts.readonly&amp;state=STATE&amp;idp_hint=26481189-e3f7-433f-804b-9643a025806a</code>.  That successfully directs the user to google, gets consent for contacts, and redirects the user back to <code>http://localhost:9011/api/identity-provider/login?state=STATE&amp;code=4/0AVG7fiTXd3CnD-ff3ga7Zs5BXgHoUbvnPw&amp;scope=email%20profile%20https://www.googleapis.com/auth/contacts.readonly%20openid%20https://www.googleapis.com/auth/userinfo.profile%20https://www.googleapis.com/auth/userinfo.email&amp;authuser=1&amp;hd=ritza.co&amp;prompt=consent</code>. That doesn't seem to do anything though. I realised I'm supposed to redirect the user back to the app, then call the FusionAuth API from the server. Making progress here slowly...</li>
</ul>
]]></description><link>https://fusionauth.io/community/forum/topic/2788/how-to-get-google-contacts-from-an-app-using-fusionauth</link><generator>RSS for Node</generator><lastBuildDate>Mon, 15 Jun 2026 14:27:28 GMT</lastBuildDate><atom:link href="https://fusionauth.io/community/forum/topic/2788.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 22 Oct 2024 09:18:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to get Google contacts from an app using FusionAuth on Thu, 24 Oct 2024 10:02:47 GMT]]></title><description><![CDATA[<p dir="auto">Oh, it's still an open bug - <a href="https://github.com/FusionAuth/fusionauth-issues/issues/2574" rel="nofollow ugc">https://github.com/FusionAuth/fusionauth-issues/issues/2574</a>. I'll ask there.</p>
]]></description><link>https://fusionauth.io/community/forum/post/7583</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/7583</guid><dc:creator><![CDATA[fusionauth.qhj5e]]></dc:creator><pubDate>Thu, 24 Oct 2024 10:02:47 GMT</pubDate></item><item><title><![CDATA[Reply to How to get Google contacts from an app using FusionAuth on Thu, 24 Oct 2024 09:57:50 GMT]]></title><description><![CDATA[<p dir="auto">I've successfully linked a FA user to a Google user with the identity provider API, and the link API, but the forum post this article is based on said <code>They'll also have a link that is accessible via the Link API. That link will contain the refresh token in the token field.</code></p>
<p dir="auto">However, calling <a href="https://fusionauth.io/docs/apis/identity-providers/links#retrieve-a-link" rel="nofollow ugc">https://fusionauth.io/docs/apis/identity-providers/links#retrieve-a-link</a>, gets the JSON below, containing NO access token for Google. Now I'm completely stuck, please advise:</p>
<pre><code>    data: {
          identityProviderLink: {
            displayName: 'richard@ritza.co',
            identityProviderId: '26481189-e3f7-433f-804b-9643a025806a',
            identityProviderName: 'fago',
            identityProviderType: 'OpenIDConnect',
            identityProviderUserId: '110494278199559678180',
            insertInstant: 1729762805435,
            lastLoginInstant: 1729762805435,
            tenantId: 'd7d09513-a3f5-401c-9685-34ab6c552453',
            token: '',
            userId: '00000000-0000-0000-0000-111111111111'
          }
</code></pre>
]]></description><link>https://fusionauth.io/community/forum/post/7582</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/7582</guid><dc:creator><![CDATA[fusionauth.qhj5e]]></dc:creator><pubDate>Thu, 24 Oct 2024 09:57:50 GMT</pubDate></item><item><title><![CDATA[Reply to How to get Google contacts from an app using FusionAuth on Wed, 23 Oct 2024 10:20:26 GMT]]></title><description><![CDATA[<p dir="auto">Here's my current code:</p>
<pre><code>&lt;a href="https://accounts.google.com/o/oauth2/v2/auth?client_id=535042435541-eridnie9d09pa69dsq1hh066ushvp4e0.apps.googleusercontent.com&amp;redirect_uri=http://localhost:3000/fago&amp;response_type=code&amp;scope=openid%20email%20profile%20https://www.googleapis.com/auth/contacts.readonly&amp;state=STATE"&gt;

router.get("/fago", async function (req, res, next) {
  console.log("IN FAGO");
  try {
    if (req.query.state != "STATE") {
      throw new Error(
        "State anti-forgery token returned from Google does not match token sent",
      );
    }
    const params = {
      applicationId: "e9fdb985-9173-4e01-9d73-ac2d60d1dc8e",
      identityProviderId: "26481189-e3f7-433f-804b-9643a025806a",
      data: {
        code: req.query.code,
        redirect_uri: "http://localhost:3000/fago",
      },
    };
    const url =
      "http://localhost:9011/api/identity-provider/login?idp_hint=26481189-e3f7-433f-804b-9643a025806a";
    const results = await axios.post(url, params);
    console.dir(params.data.code);
    console.dir(results.status + " " + results.statusText);
    console.dir(results.data);
    res.redirect("/account");
  } catch (error) {
    next(error);
  }
});
</code></pre>
<p dir="auto">I'm being returned by FusionAuth status code 232 (which I can't find a meaning for anywhere), and the only field in <code>data</code> is <code>pendingIdPLinkId</code>. I don't know how to get a Google Calendar access token from this.</p>
]]></description><link>https://fusionauth.io/community/forum/post/7572</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/7572</guid><dc:creator><![CDATA[fusionauth.qhj5e]]></dc:creator><pubDate>Wed, 23 Oct 2024 10:20:26 GMT</pubDate></item></channel></rss>