Giter VIP home page Giter VIP logo

ballerina-stackoverflow-gsheet's Introduction

Ballerina-Stackoverflow-Spreadsheet Integration

This is a ballerina project to integrate stackoverflow and google sheets

This guide walks you through the process of running this repo which use Stackoverflow and Google Sheets along with Ballerina language.

The following sections provide you with information on how to get started with Stackoverflow Spreadsheet Integration.

What you’ll build

To understand how you can use Ballerina API connectors, in this sample we use StackExhchange API to get data from a user account and we use the Spreadsheet connector to store the retrieved data to a Google Sheet.

You can retrieve what ever details you like from a stack exchange account (question details are retrieved in this scenario), then use the Ballerina Google Spreadsheet connector and store that data to a spreadsheet.

In order to try something other than questions you can check out the stackexchange docs.

Compatibility

Ballerina Language Version Stack Exchange API Version Google Spreadsheet API Version
1.0.1 V2.2 V4

Prerequisites

$ ballerina pull wso2/gsheets4
  • A Text Editor or an IDE

Tip: For a better development experience, install one of the following Ballerina IDE plugins: VSCode, IntelliJ IDEA

Getting Started

Cloning

Clone this repo to a preferred local directory

$ git clone https://github.com/ashera96/ballerina-stackoverflow-gsheet.git

Configurations

  • Go through the following steps to obtain credentials and tokens for Google Sheets API.

    1. Visit Google API Console, click Create Project, and follow the wizard to create a new project.
    2. Enable the Google Sheets APIs for the project.
    3. Go to Credentials -> OAuth consent screen, enter a product name to be shown to users, and click Save.
    4. On the Credentials tab, click Create credentials and select OAuth client ID.
    5. Select an application type, enter a name for the application, and specify a redirect URI (enter https://developers.google.com/oauthplayground if you want to use OAuth 2.0 playground to receive the authorization code and obtain the access token and refresh token).
    6. Click Create. Your client ID and client secret appear.
    7. In a separate browser window or tab, visit OAuth 2.0 playground, select the required Google Sheets API V4 scopes, and then click Authorize APIs.
    8. When you receive your authorization code, click Exchange authorization code for tokens to obtain the refresh token and access token.
  • Go through the following steps to obtain credentials for Stack Exchange API.

    1. Get your stackoverflow user id
  • Create a Google Sheet as follows from the same Google account you have obtained the client credentials and tokens.

Image of the created spreadsheet

  • Obtain the spreadsheet id by extracting the value between the "/d/" and the "/edit" in the URL of your spreadsheet.

    You must configure the ballerina.conf configuration file with the above obtained tokens, credentials and other important parameters as follows.

    ACCESS_TOKEN="access token"
    CLIENT_ID="client id"
    CLIENT_SECRET="client secret"
    REFRESH_TOKEN="refresh token"
    SPREADSHEET_ID="spreadsheet id you have extracted from the sheet url"
    SHEET_NAME="sheet name of your Goolgle Sheet. For example in above example, SHEET_NAME="StackoverflowQuestions"
    STACKOVERFLOW_ID="stackoverflow id"
    

    At the end of this step you should have a ballerina.conf configuration file at the same level of Ballerina.toml with filled parameters.

Building

$ ballerina build -a

After the build is successful, there will be a .jar file inside the target directory. That executable can be executed as follows.

Running

$ ballerina run target/bin/stackoverflow_gsheet.jar

If the above mentioned instructions were properly followed the retrieved details should be added to the spreadsheet as shown below.

Image of the spreadsheet with the retrieved data

ballerina-stackoverflow-gsheet's People

Contributors

ashera96 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.