Out of the box services


#1

I have noticed that some services are supported out of the box for authenticating the user, like mailchimp with the example below.
What other services are supported in a similar fashion? I am specifically interested with Google in order to integrate with google drive.
What’s an alternative way of doing that if that is not support out of the box?

"account": {
        "title": "Choose Service Provider",
        "type": "object",
        "format": "account",
        "services": ["mailchimp"],
        "order": 0,
        "description": "Login with your account to fetch your Mailchimp account profiles.",
        "required": true
      },

#2

To use the Google service, use the service alias google.


#3

cool! is there a list somewhere of all the services one can access?


#4

For security reasons, you can’t see a list of all the services. Services like Google take only moments to set up since they already have OAuth 2.0 setup, you just need a Google Cloud account. From there you get the client ID, OAuth URL, OAuth token URL etc… https://developers.google.com/identity/protocols/OAuth2
Working on making our docs more clear for the future and I appreciate if you have any feedback :slight_smile:


#5

Thanks for your quick reply. yes, your documentation is progressing nicely.
I think I got it now. I do have to create a service and populate it with all the information I got from google cloud account, right?
I got confused b/c with mailchimp I needn’t do a thing. just specify the service.


#6

In order to make your app pass through moderation, it really should only use the services you set up on your developer account. Although you can use the aliases for Google and Mail-Chimp for testing, you really should create your own.

This is because the client ID’s from those services is used by Google and others to rate limit and track the number of time your app uses the service. If one app floods the service, that app will likely be cut off.


#7

Ok, so I created a service of my own that redirect to google for authentication. I can even see that it calls my endpoint according to the hook I set.
Here is what I am trying to do: I want to write to a google doc the text the site visitor typed in a textbox.
Do I still need my own server (that the hook points to) even if I am not interested with changing dynamically the values in the install process?
I need to set a google oauth client but for that I need the token. How can I get the token in order to create that client?


#8

If you don’t need to change the install options, no you won’t need a hook. The only way to use the token from Google though is on a hook, so if writing a google doc requires that token from the service you created, then you must make a hook.
An easy way to do this though, could be to write a Cloudflare Worker on a zone active on Cloudflare. I could help you write that worker if you are interested.


#9

Thanks. I guess this is true with every oauth service right? Also mailchimp. One needs a token of some sort to access the api.

Yeah, that would be great if you could show me how to write it. Thanks for the offer!


#10

Hi Amir,

Here is the script I used to respond to a webhook using a worker:

addEventListener('fetch', (event) => {
  return event.respondWith(hookResponse(event.request))
})

/**
 * Fetch the authenticated hook request and return an approriate response
 * using the token
 * @param {Request} request
 */
async function hookResponse(request) {
    let reqJSON =  await request.json()  
    let install = reqJSON.install
    let token = reqJSON.authentications.account.token.token
    
    // Use token to do something
    // Obiviously please don't make their token public and use it wisely 
    install.options.message = "hello world here is my token " + token
    
    let finalRes = Object.assign({install}, {"proceed": true})
    return new Response(JSON.stringify(finalRes))

  
  }
  // To test send a similar post body to the hook endpoint you set up
// {"event":"[The event name]","user":{"id":"7c5dae5552338874e5053f2534d2767a","email":"[email protected]"},"site":{"id":"023e105f4ecef8ad9ca31a8372d0c353","name":"example.com","orgId":"7c5dae5552338874e5053f2534d2767a","active":true},"version":{"tag":"1.0.0"},"install":{"schema":{"properties":{}},"options":{},"productId":"gold-plan"},"authentications":{"account":{"token":{"token":"94094f928a82c6d5171c75f52fc1818f","type":"Bearer","expiration":"201X-01-15T23:04:03.776190171Z","extra":{}}}},"org":{"title":"Acme Inc.","id":"112233aabbcc8874e5053f2534d2767a"},"app":{"id":"AABBCC123-00","title":"Example App","alias":"example-app","orgId":"112233aabbcc172340ce4cfe4560fdf6"},"metadata":{}}

Hope this helped!


#11

cool. thanks a lot.
Based on what I see workers are associated to sites. does it matter which site I create the worker for? do I need to setup a hook that point to that worker route?
And one last question: why can’t I use that option even if i am trying to change the install params? is there any limitation?