How to access Google Search Console API data through Sign In with Google for a site migration tool? Answered

Post author
Luke Bonnici

Hi all! Wondering if I can access a users Google Search Console data if the user Signs In With Google? Really need this for the project I’m working on - it’s a must 🙂

I’ve built an application that automatically creates 301-redirect documents called rapid301.com.

Users enter the current and staging domain and it scrapes the sites - I get the sitemap. Some users have have requested that I show the number of backlinks and traffic on each link within the migration, Search Console has this data.

So if I entered rapid301.com and my Google Account has the Search Console data for that site, I would want that to display that information in the migration.

I hope that makes sense! Happy to answer any other questions.

Basically when a user logs in, I need to prompt them to give permission for Google Search Console as I need access to the API.

Comments

7 comments

  • Comment author
    Raquel Lopez

    Ahh I see, well, the Google SSO integration that Memberstack currently provides is only for authentication. You'll have to develop the integration with the Web Console on the side.

    When you create the OAuth consent screen of the Google Cloud app to allow permissions for authentication, you can also request the permissions to add the Search Console as an additional scope.

    0
  • Comment author
    Luke Bonnici

    Hi Raquel, thanks for the detailed reply and screenshots. 

    I have added Google Auth and I can create an account. In order to access the search console information, I need the access code.

    You can see that I have added the GSC API into my sensitive scopes.

    After the user signs up / logs in, I need to exchange their authorization code for an access token to pass along with the requests.

    Does memberstack have a way to get the access token? And if not do you have a workaround? It is mission critical for the feature that I can access GSC data!

    0
  • Comment author
    Raquel Lopez

    The SSO Provider authentication method only responds with access tokens to access Memberstack user logged in info (unless Tyler Bell or Duncan Hamra decide to send the token from google as a response of the method ).

    However, like I previously said, integration with something other than Oauth 2.0 authentication purposes it has to be developed custom. Memberstack don't offer a native solution so far to enable you to access other Google API functions. I don't have a specific workaround since I haven't had the need to use the Google API so far advanced, however I would recommend create another Google app to allow GSC scope and to get the access response in your server (you will have to create an additional step in your users onboarding flow to get those permissions).

    0
  • Comment author
    Luke Bonnici

    Hi Raquel, thanks for the response.

    Duncan Hamra, Tyler Bell, I’d love to know if Memberstack has the ability to pull the access token from the Member Object so that I could use it like:

    headers: { Authorization: Bearer ${member.GoogleAccessToken } }

    I can’t seem to find documentation on this, I did find a forum post with a similar request from 5 months ago so hoping it’s now possible.

    I’d also love to know if I can gain access to the response object so that if not, I can do it manually.

    I currently have it implemented via attributes but will write the JS if I have to. Hoping it can be done in a much simpler way so thought to ask!

    Would also be a killer feature as it would property open up the Google API.

    0
  • Comment author
    Tyler Bell

    I can confirm that this is not possible.

    0
  • Comment author
    Luke Bonnici

    Thanks. So then the fix is to handle the signup / login to memberstack with JS. I have read this documentation and it looks like the access token is returned in the response via code (just not no code)

    Is that correct?

    0
  • Comment author
    Raquel Lopez

    The access token returned using Memberstack authentication methods is will return a Memberstack token, not Google's. You can use that JWT token to identify your user against Memberstack or a custom server that is integrated with Memberstack.

    0

Please sign in to leave a comment.