Skip to content

Instantly share code, notes, and snippets.

View tristansokol's full-sized avatar

Tristan Sokol tristansokol

View GitHub Profile
var SquareConnect = require('square-connect');
var defaultClient = SquareConnect.ApiClient.instance;
// Configure OAuth2 access token for authorization: oauth2
var oauth2 = defaultClient.authentications['oauth2'];
oauth2.accessToken = "sq0atp-xxxxxxxx";
var api = new SquareConnect.LocationsApi();
api.listLocations().then(function(data) {
@tristansokol
tristansokol / callback.php
Last active November 22, 2017 20:45
php oauth example
<pre>
<?php
$client_id = 'sq0idp-xxx';
$client_secret = 'sq0csp--xxxx';
$redirect_uri= "http://localhost:8080/callback.php";
$authorization_code = $_GET['code'];
if(!$authorization_code){
die('something went wrong!');
}
@tristansokol
tristansokol / callback.php
Created November 22, 2017 18:57
callback for php oauth example
<?php
$client_id = '';
$client_secret = '';
$redirect_uri= "http://localhost:8080/callback.php";
$authorization_code = $_GET['code'];
if(!$authorization_code){
die('something went wrong!');
}
@tristansokol
tristansokol / index.php
Created November 22, 2017 18:55
php oauth example
<a href="https://connect.squareup.com/oauth2/authorize?client_id=sq0idp-gbQhcOCpmb2X4W1588Ky7A">Authorize App</a>
# use Square's SDK to make your job easier
import squareconnect
from squareconnect.apis.customers_api import CustomersApi
from squareconnect.models.create_customer_card_request import CreateCustomerCardRequest
# setup authorization with your access token
squareconnect.configuration.access_token = 'sandbox-sq0atb-XXXXXXXX'
# using a hardcoded nonce, but in a production evironment you'll need to use the
# payment form:
@tristansokol
tristansokol / index.js
Created October 21, 2017 18:41
mongodb - google cloud functions write example
exports.helloWorld = function helloWorld(req, res) {
//Connect to MongoDB Atlas
var MongoClient = require('mongodb').MongoClient;
var uri = "mongodb://user:[email protected]:27017,cluster-shard-00-01-6chsu.mongodb.net:27017,cluster-shard-00-02-6chsu.mongodb.net:27017/test?ssl=true&replicaSet=Cluster-shard-0&authSource=admin";
MongoClient.connect(uri, function(err, db) {
//check for connection errors
if (err) res.status(400).send(err);
//Read the data from the incoming request & add it to an object to insert
var message = req.body.message;
# use Square's SDK to make your job easier
import squareconnect
from squareconnect.apis.v1_employees_api import V1EmployeesApi
from squareconnect.models.v1_employee import V1Employee
# setup authorization with your access token
squareconnect.configuration.access_token = 'sq0atp-XXXXXXXX'
# create an instance of the Location API class
api_instance = V1EmployeesApi()
<?php
require_once(__DIR__ . '/vendor/autoload.php');
SquareConnect\Configuration::getDefaultConfiguration()->setAccessToken('XXXX');
$customers_api = new SquareConnect\Api\CustomersApi();
$customer = new \SquareConnect\Model\CreateCustomerRequest();
$customer->setGivenName('Stacy');
# use Square's SDK to make your job easier
import squareconnect
from squareconnect.apis.locations_api import LocationsApi
# setup authorization with your access token
squareconnect.configuration.access_token = 'XXXXXXXXXXXXX'
# create an instance of the Location API class
api_instance = LocationsApi()
# load the gem
require 'square_connect'
# setup authorization with a personal access token
SquareConnect.configure do |config|
config.access_token = 'sq0atp-XXXXXXXXXXXXX'
end
#create a new API instance
api_instance = SquareConnect::CustomersApi.new