Building with Oauth

Blockspring now handles OAuth in your functions. Build Gmail visualizations, upload files to Dropbox, and analyze your Uber history in minutes.

Let's walk through how to get started with the APIs below in your functions:

Let's Build This Function: What languages does a developer code in? (finished product)

  1. Clone the function: nodejs | python | ruby | r | php.

  2. To the right of the editor, find the You must link to a Github app notification. Click Add new. You'll see a Blockspring form pop open.

  3. Visit https://github.com/settings/applications/new to register an app with GitHub and get your Client ID and Client Secret.

  4. On the GitHub form, under "Authorization callback URL" enter: https://open.blockspring.com/. You can fill in the app name, homepage url, and description as desired.

  5. Click "Register Application".

  6. Copy the Client ID and Client Secret that GitHub gives you into the Blockspring form and click Submit.

  7. Go back to the Blockspring code editor, click Choose existing, and select the app you just created on Blockspring.

  8. Click Login with GitHub and you're ready to Test Run or Publish your new GitHub function.

As you build new GitHub functions, you'll want to ask your users for various permissions. Learn more permissions and scopes on GitHub: https://developer.github.com/v3/oauth/#scopes.

Let's Build This Function: Visualize your tagged Facebook locations (finished product)

  1. Clone the function: nodejs | python | ruby | r | php.

  2. To the right of the editor, find the You must link to a Facebook app notification. Click Add new. You'll see a Blockspring form pop open.

  3. Visit https://developers.facebook.com/ to register an app with Facebook and get your AppID and AppSecret.

  4. Click Apps, then Add a New App, then Website.

  5. Give your app any name and category, and click Skip Quickstart.

  6. In the new window go to Settings and under App Domains enter https://open.blockspring.com/.

  7. Copy the AppID and AppSecret that Facebook gives you into the Blockspring form and click Submit.

  8. Go back to the Blockspring code editor, click Choose existing, and select the app you just created on Blockspring.

  9. Click Login with Facebook and you're ready to Test Run or Publish your new Facebook function.

Before others can use your function, Facebook needs to approve your use of custom scopes (user_tagged_places,user_photos,user_videos,user_status). Back in your app settings on Facebook, go to Status & Review, click Start a Submission, and choose these custom permissions from the list. Any custom scope besides email, public_profile, and user_friends requires this process. After your app is approved, you can set it to Public on Facebook.

To learn more about custom permissions visit https://developers.facebook.com/docs/facebook-login/permissions/v2.2.

Let's Build This Function: Validate a company's email domains (finished product)

  1. Clone the function: nodejs | python | ruby | r | php.

  2. To the right of the editor, find the You must link to a LinkedIn app notification. Click Add new. You'll see a Blockspring form pop open.

  3. Visit https://www.linkedin.com/secure/developer to register an app with LinkedIn and get your Consumer Key / API Key and Consumer Secret / Secret Key.

  4. Click Add New Application.

  5. Click to add all of the scopes (we can edit them later), set Live Status to Live, and under Oauth 2.0 Redirect URLs enter https://auth.blockspring.com/users/auth/bslinkedin/callback. The rest of the required inputs are up to you.

  6. Click Add Application.

  7. Copy the Consumer Key / API Key and Consumer Secret / Secret Key that LinkedIn gives you into the Blockspring form and click Submit.

  8. Go back to the Blockspring code editor, click Choose existing, and select the app you just created on Blockspring.

  9. Click Login with LinkedIn and you're ready to Test Run or Publish your new LinkedIn app.

To learn more about custom permissions and scopes visit https://developer.linkedin.com/documents/authentication#granting.

Let's Build This Function: Word cloud your emails (finished product)

  1. Clone the function: nodejs | python | ruby | r | php.

  2. To the right of the editor, find the You must link to a Google app notification. Click Add new. You'll see a Blockspring form pop open.

  3. Visit https://console.developers.google.com/project. Create a project, or select an existing one.

  4. Click on APIs and Auth.

  5. Click Consent Screen. Name your app however you want and Save.

  6. Under APIs and Auth go to Credentials.

  7. Create new Client ID and choose Web Application.

  8. Under authorized redirect URIs enter https://auth.blockspring.com/users/auth/bsgoogle/callback. Delete the Javascript Origins, fill out the rest of the info as desired, and Submit.

  9. Copy the Client ID and Client Secret that Google gives you into the Blockspring form and click Submit.

  10. Go back to the Google interface for one more step: click APIs and Auth, then APIs, and finally enable the Google+ API.

  11. Whenever you want to use a new API with your function, just enable that API in this Google console. For this example you'll always want to enable the Gmail API.

To learn more about custom permissions and scopes visit https://developers.google.com/oauthplayground/.

Let's Build This Function: Geocode your addresses (finished product)

  1. Clone the function: nodejs | python | ruby | r | php.

  2. To the right of the editor, find the You must link to a Foursquare app notification. Click Add new. You'll see a Blockspring form pop open.

  3. Visit https://foursquare.com/developers/apps. Click Create a new app.

  4. Under Redirect URIs enter https://open.blockspring.com/. All the other inputs you can enter as desired.

  5. Copy the Client ID and Client Secret that Foursquare gives you into the Blockspring form and click Submit.

Let's Build This Function: Save URL screenshot to Dropbox (finished product)

  1. Clone the function: nodejs | python | ruby | r | php.

  2. To the right of the editor, find the You must link to a Dropbox app notification. Click Add new. You'll see a Blockspring form pop open.

  3. Visit https://www.dropbox.com/developers/apps/create. Click Dropbox API app, then Files and datastores, then No, then All file types, and finally set a name and click Create app.

  4. Under Redirect URIs enter https://auth.blockspring.com/users/auth/bsdropbox/callback. All the other inputs you can enter as desired.

  5. Copy the App key and App secret that Dropbox gives you into the Blockspring form and click Submit.

Note - Dropbox requires you to apply for production when your function is ready to be used by others.

Let's Build This Function: Should I join this Meetup group? (finished product)

  1. Clone the function: nodejs | python | ruby | r | php.

  2. To the right of the editor, find the You must link to a Meetup app notification. Click Add new. You'll see a Blockspring form pop open.

  3. Visit https://secure.meetup.com/meetup_api/oauth_consumers/. Click Create a new consumer.

  4. Under Redirect URI enter https://open.blockspring.com/. All the other inputs you can enter as desired.

  5. Copy the Key and Secret that Meetup gives you into the Blockspring form and click Submit.

Check out http://www.meetup.com/meetup_api/docs/ for an overview of the API calls you can make.

Let's Build This Function: Get an Email's Social Accounts (finished product)

  1. Clone the function: nodejs | python | ruby | r | php.

  2. To the right of the editor, find the You must link to a Angellist app notification. Click Add new. You'll see a Blockspring form pop open.

  3. Visit https://angel.co/api/oauth/clients/new.

  4. Under Callback URL enter https://auth.blockspring.com/users/auth/bsangellist/callback. All the other inputs you can enter as desired.

  5. Copy the Client ID from Angellist into the Blockspring form. Also, you should receive a Client Secret in your email. Copy that into the Blockspring form too and click Submit.

Check out https://angel.co/api for an overview of the API calls you can make.

Let's Build This Function: Monthly StackOverflow question counts by language (finished product)

  1. Clone the function: nodejs | python | ruby | r | php.

  2. To the right of the editor, find the You must link to a StackExchange app notification. Click Add new. You'll see a Blockspring form pop open.

  3. Visit http://stackapps.com/apps/oauth/register.

  4. Under OAuth Domain enter https://open.blockspring.com/. All the other inputs you can enter as desired.

  5. Copy the Client ID, Client Secret, and Key into the Blockspring form. Click Submit.

  6. As you write the code for your function, don't forget to include the Key along with the stackexchange_token in each API call.

Check out https://api.stackexchange.com/docs/authentication#scope for an overview of API scopes.

Coming soon!
Coming soon!
Coming soon!
Coming soon!
Coming soon!
Coming soon!
Coming soon!
Coming soon!
Coming soon!
Coming soon!
Coming soon!
Coming soon!
Coming soon!
Coming soon!

Here's how we're handling Oauth for you in the background:

  1. You indicate which API(s) your function requires.
  2. We generate sign in buttons for your function.
  3. When your users sign in to each API (eg "Sign in with Facebook"), we save their access tokens for you.
  4. When a user runs your function, access tokens are automatically passed along.

If you love this feature or want us to support a new API, let us know (in the chat below)!