Skip to content

Latest commit

 

History

History
609 lines (547 loc) · 30 KB

other-tools.md

File metadata and controls

609 lines (547 loc) · 30 KB

Frameworks

Scrum

Tools

tasks automation & business flows & connections between applications

authentication

Amazon Cognito

okta.com

auth0.com

authy (twilio)

Yahoo authentication

!!! important: OpenID Connect Permissions: !!!

App ID
${APP_ID}
Client ID (Consumer Key)
${CLIENT_ID}
Client Secret (Consumer Secret)
${CLIENT_SECRET}

request authentication

# step 1
https://api.login.yahoo.com/oauth2/request_auth?client_id=${CLIENT_ID}&response_type=code&redirect_uri=https://ec2-52-29-176-00.eu-central-1.compute.amazonaws.com&scope=profile,email&nonce=6b526ab2-c0eb

# step 2 
# RESPONSE "Yahoo code"
# code=${CLIENT_CODE}

request Token

curl -X POST https://api.login.yahoo.com/oauth2/get_token --data "code=${CLIENT_CODE}&grant_type=authorization_code&client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}&redirect_uri=https://ec2-52-29-176-00.eu-central-1.compute.amazonaws.com&response_type=code"
curl --verbose -X POST --data "access_token=${ACCESS_TOKEN}" https://api.login.yahoo.com/openid/v1/userinfo

encode string for header request

import base64
encodedBytes = base64.b64encode(f"{client_id}:{client_secret}".encode("utf-8"))
encodedStr = str(encodedBytes, "utf-8")

Google authentication

links

google project

it is Working only from remote ( AWS EC2 ) host

<html lang="en">
  <head>
    <meta name="google-signin-scope" content="profile email">
    <meta name="google-signin-client_id" content="273067202806-6cc49luinddclo4t6.apps.googleusercontent.com">
    <script src="https://apis.google.com/js/platform.js" async defer></script>
  </head>
  <body>
    <div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark">google button</div>
    <script>
      function onSignIn(googleUser) {
        // Useful data for your client-side scripts:
        var profile = googleUser.getBasicProfile();
        console.log("ID: " + profile.getId()); // Don't send this directly to your server!
        console.log('Full Name: ' + profile.getName());
        console.log('Given Name: ' + profile.getGivenName());
        console.log('Family Name: ' + profile.getFamilyName());
        console.log("Image URL: " + profile.getImageUrl());
        console.log("Email: " + profile.getEmail());

        // The ID token you need to pass to your backend:
        var id_token = googleUser.getAuthResponse().id_token;
        console.log("ID Token for backend: " + id_token);
      }
    </script>


    <a href="#" onclick="signOut();">Sign out</a>
    <script>
      function signOut() {
        var auth2 = gapi.auth2.getAuthInstance();
        auth2.signOut().then(function () {
          console.log('User signed out.');
        });
      }
    </script>
    
  </body>
</html>

google rest api services, collaboration with google rest api service

example of using via rest client postman

Links

GDRIVE_URL=https://www.googleapis.com

## obtain token for REST API collaboration 
# register REDIRECT_URL via "OAuth 2.0 Client IDs" "Authorised redirect URIs": https://console.cloud.google.com/apis/credentials
REDIRECT_URL=https://google.com
CLIENT_ID=5344876.....-scmq9ph1tbrvva7p353......apps.googleusercontent.com
SCOPE=https://www.googleapis.com/auth/drive.metadata.readonly
# open in browser
x-www-browser https://accounts.google.com/o/oauth2/v2/auth?scope=${SCOPE}&include_granted_scopes=true&response_type=token&state=state_parameter_passthrough_value&redirect_uri=${REDIRECT_URL}&client_id=${CLIENT_ID}
# copy from redirect url "access_token" field
# curl -X GET -v  https://accounts.google.com/o/oauth2/token

TOKEN="ya29.a0AfB_byBl7oToNlM..."
curl -H "Authorization: Bearer $TOKEN" ${GDRIVE_URL}/drive/v3/about
curl -H "Authorization: Bearer $TOKEN" ${GDRIVE_URL}/drive/v3/files

token update

json_body='{"grant_type":"authorization_code","code":"****my_token","client_id":"******.googleusercontent.com","client_secret":"*******client_secret","redirect_uri":"http://localhost:3000"}'
curl -X POST https://oauth2.googleapis.com/token --data ${json_body}

captcha

google captcha

reCaptcha client code reCaptcha server code my own project with re-captcha

index file

<html>
        <head>
                <script src="https://www.google.com/recaptcha/api.js?render=6LcJIwYaAAAAAIpJLnWRF44kG22udQV"></script>
          
<script>
      function onClick(e) {
        //e.preventDefault();     
              console.log("start captcha");
        grecaptcha.ready(function() {
          grecaptcha.execute('6LcJIwYaAAAAAIpJLnWRF44kG22udQV', {action: 'submit'}).then(function(token) {
              console.log(token);                                     
          });
        });
      }
  </script>

        </head>
        <body>
                <button title="captcha" onclick="onClick()" >captcha </button>
        </body>
</html>

start apache locally in that file

docker run --rm --name apache -v $(pwd):/app -p 9090:8080 bitnami/apache:latest
x-www-browser http://localhost:9090/index.html

example of checking response

# google key
GOOGLE_SITE_KEY="6Ldo3dsZAAAAAIV6i6..."
GOOGLE_SECRET="6Ldo3dsZAAAAACHkEM..."

CAPTCHA="03AGdBq26Fl_hBnLn7lNf5s53xTRN23yt1OeS4Y7vV6ARSEehMuE_0uKL..."
echo $CAPTCHA
curl -X POST -F "secret=$GOOGLE_SECRET" -F "response=$CAPTCHA" https://www.google.com/recaptcha/api/siteverify

address

US Zip codes

# Plano TX
curl https://public.opendatasoft.com/explore/dataset/us-zip-code-latitude-and-longitude/table/?q=plano

# coordinates
curl -X GET https://public.opendatasoft.com/api/records/1.0/search/?dataset=us-zip-code-latitude-and-longitude&q=Plano&facet=state&facet=timezone&facet=dst

Google Maps

google maps api links

Google maps platform, document root Request API Key How to use api keys Example of showing credentials cloud billing console

project links

my google project dashboard create new web project create new web project project settings dashboard of project, API and services OAuth consent screen:-> Any User in google Account OAuth credentials:-> select OAuth Client IDs->ClientId

Google maps REST API

place search place details Review, for specific location with additional authentication by Google

# activate api key
 YOUR_API_KEY="AIzaSyDTE..."
echo $YOUR_API_KEY

# attempt to find place by name 
# x-www-browser https://developers.google.com/places/web-service/search
SEARCH_STRING="Fallahi%20Zaher%20Attorney"
curl -X GET "https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=${SEARCH_STRING}&inputtype=textquery&fields=place_id,photos,formatted_address,name,rating,geometry&key=${YOUR_API_KEY}"
# place_id="ChIJl73rFVTf3IARQFQg3ZSOaKo"

# detail about place (using place_id) including user's reviews
# x-www-browser https://developers.google.com/places/web-service/details
curl -X GET "https://maps.googleapis.com/maps/api/place/details/json?place_id=${place_id}&fields=name,rating,review,formatted_phone_number&key=$YOUR_API_KEY"
# unique field here - time

more that 5 review API:

sms broadcasting

e-mail broadcasting

sendgrid api

# get all templates
curl -X "GET" "https://api.sendgrid.com/v3/templates" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json"

# get template
curl --request GET \
--url https://api.sendgrid.com/v3/templates/d-5015e600bedd47b49e09d7e5091bf513 \
--header "authorization: Bearer $API_KEY" \
--header 'content-type: application/json'
# send 
curl --request POST \
--url https://api.sendgrid.com/v3/mail/send \
--header "authorization: Bearer $API_KEY" \
--header 'content-type: application/json' \
--data @email-data.json

email-data.json

{
        "personalizations":[
                {
                        "to":[
                                {"email":"vitalii.cherkashyn@gmail.com","name":"Vitalii"}
                        ],
                        "subject":"test sendgrid"
                }
        ],
        "content": [{"type": "text/plain", "value": "Heya!"}],
        "from":{"email":"vitalii.cherkashyn@gmail.com","name":"Vitalii"},
        "reply_to":{"email":"vitalii.cherkashyn@gmail.com","name":"Vitalii"}
}

redirect

screenshots

  • site-shot.com
USER_KEY=YAAIEYK....
curl -L -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: text/plain"  -H "userkey: $USER_KEY" -F "DEBUG=True" -F "url=google.com" https://api.site-shot.com 

curl -L -X POST -H "Accept: text/plain"  -H "userkey: $USER_KEY" -F "DEBUG=True" -F "url=google.com" https://site-shot.com?DEBUG=True

curl -X POST -H "userkey:$USER_KEY" https://api.site-shot.com/?url=google.com

curl -X POST -H "userkey:$USER_KEY" -F "url=http://www.emsylaw.com" -F "format=jpg" -o emsylaw.jpg https://api.site-shot.com 

image compression

shortpixel.com

url1="https://staging.s3.us-east-1.amazonaws.com/img/dir/chinese/bu-2739.jpeg"
body='{"key": "'$SHORTPIXEL_KEY'", "plugin_version": "dbrbr", "lossy": 2, "resize": 0, "resize_width": 0, "resize_height": 0, "cmyk2rgb": 1, "keep_exif": 0, "convertto": "", "refresh": 0, "urllist": ["'$url1'"], "wait": 35}'

curl -H "Content-Type: application/json" --data-binary $body -X POST https://api.shortpixel.com/v2/reducer.php

image upload

imgbb

# https://api.imgbb.com/
API_KEY_IMGBB=9f......
IMAGE_FILE=handdrawing-01.jpg
IMAGE_NAME="${IMAGE_FILE%.*}"
echo $IMAGE_FILE"  "$IMAGE_NAME

curl --location --request POST "https://api.imgbb.com/1/upload?&key=$API_KEY_IMGBB&name=${IMAGE_NAME}" \
 -F "image=@${IMAGE_FILE}" -H "accept: application/json" | jq . 

feedback collector

canny

export API_KEY=...
# boards list
curl https://canny.io/api/v1/boards/list -d apiKey=$API_KEY | jq .
curl https://canny.io/api/v1/boards/list?apiKey=$API_KEY | jq .

# board by id
export BOARD_ID=5f8cba47...
curl https://canny.io/api/v1/boards/retrieve -d apiKey=$API_KEY -d id=BOARD_ID | jq .

yelp

yelp_id='law-office-of-spojmie-nasiri-pleasanton-5'

curl --location --request GET 'https://api.yelp.com/v3/businesses/law-office-of-camelia-mahmoudi-san-jose-3' \
--header "Authorization: Bearer $API_KEY"

curl --location --request GET 'https://api.yelp.com/v3/businesses/law-office-of-camelia-mahmoudi-san-jose-3/reviews' \
--header "Authorization: Bearer $API_KEY" | jq .

facebook

links

get profile_id from facebook page

curl -X GET https://www.facebook.com/$PROFILE_NAME | grep profile_owner

get access token

# https://www.facebook.com/v7.0/dialog/oauth?client_id=${APP_ID}&redirect_uri=${REDIRECT_URL}&state=state123abc
# REDIRECT_URI !!! DON'T REMOVE trailing slash !!! 
curl -X GET https://graph.facebook.com/v7.0/oauth/access_token?client_id=${APP_ID}&redirect_uri=${REDIRECT_URI}&client_secret=${APP_SECRET}&code=${CODE_PARAMETER}
# b'{"access_token":"$ACCESS_TOKEN","token_type":"bearer","expires_in":5181746}'

get profile info

curl -X GET https://graph.facebook.com/v7.0/me?fields=id,last_name,name&access_token=${ACCESS_TOKEN}"

get ratings

# $PROFILE_ID/ratings?fields=reviewer,review_text,rating,has_review
curl -i -X GET \
 "https://graph.facebook.com/v8.0/$PROFILE_ID/ratings?fields=reviewer%2Creview_text%2Crating%2Chas_review&access_token=$ACCESS_TOKEN"

# https://developers.facebook.com/tools/explorer/?method=GET&path=$PROFILE_ID%2Fratings%3Ffields%3Drating%2Creview_text%2Creviewer&version=v8.0
# https://developers.facebook.com/tools/explorer/${APP_ID}/?method=GET&path=${PROFILE_NAME}%3Ffields%3Dreview_text&version=v8.0

possible fields:

  • name
  • created_time
  • rating
  • review_text
  • recommendation_type
  • reviewer
  • has_review
 {
  "data": [
    {
      "created_time": "2020-08-17T20:40:26+0000",
      "recommendation_type": "positive",
      "review_text": "let's have a fun! it is a great company for that"
    }
  ]
}

user activities

external data

user guide user tutorials

social networks

linkedin

linkedin api

login with linkedin
<html><body>
<a href="https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id=78j2mw9cg7da1x&redirect_uri=http%3A%2F%2Fec2-52-29-176-43.eu-central-1.compute.amazonaws.com&state=my_unique_value_generated_for_current_user&scope=r_liteprofile%20r_emailaddress"> login with LinkedIn </a>
</body></html>

example of response from LinkedIn API:

http://ec2-52.eu-central-1.compute.amazonaws.com/?code=<linkedin code>&state=<my_unique_value_generated_for_current_user>
linkedin profile api
curl -X GET -H "Authorization: Bearer $TOKEN" https://api.linkedin.com/v2/me

answer example:

{"localizedLastName":"Cherkashyn","profilePicture":{"displayImage":"urn:li:digitalmediaAsset:C5103AQ..."},"firstName":{"localized":{"en_US":"Vitalii"},"preferredLocale":{"country":"US","language":"en"}},"lastName":{"localized":{"en_US":"Cherkashyn"},"preferredLocale":{"country":"US","language":"en"}},"id":"9yP....","localizedFirstName":"Vitalii"}
collaboration with Contact API

application permissions: r_emailaddress
documentation
documentation

e-commerce

:TODO: Telegram bot

shopify

x-www-browser https://$SHOPIFY_SHOP_NAME.myshopify.com &
x-www-browser https://$SHOPIFY_SHOP_NAME.myshopify.com/admin &	
# shopify product count
curl --location --header "X-Shopify-Access-Token: ${SHOPIFY_AUTH_TOKEN}" -X GET "https://${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products/count.json" 
# shopify product by id
curl --location -X GET --header "X-Shopify-Access-Token: ${SHOPIFY_AUTH_TOKEN}" "https://${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products/${1}.json" | jq .
# shopify get all products
curl --location --header "X-Shopify-Access-Token: ${SHOPIFY_AUTH_TOKEN}"  -X GET "https://${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products.json?fields=id" | jq .	
# get variants count
curl --location -X GET "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products/${PRODUCT_ID}/variants/count.json" | jq .
# shopify product variant by id
curl --location -X GET --header "X-Shopify-Access-Token: ${SHOPIFY_AUTH_TOKEN}" "https://${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-07/variants/${1}.json" | jq . 
# get metadata for product by id
curl --location -X GET "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products/${PRODUCT_ID}/metafields.json" | jq .

# shopify create product
curl -v -X POST -H "X-Shopify-Access-Token:${SHOPIFY_AUTH_TOKEN}" --data "{'product': {'title': 'test-product-remove-me', 'product_type': 'Framed Prints', 'published': True, 'vendor': 'Classy Art', 'tags': 'Furniture,Accessories,Wall Art,Category:Accessories,Category_Accessories,Category:Wall Art,Category_Wall Art,Color:Brown,Color_Brown,Product Type:Framed Prints,Product Type_Framed Prints,Brand:Classy Art,Brand_Classy Art', 'taxable': True, 'options': None, 'variants': [{'option1': None, 'option2': None, 'option3': None, 'price': 139.99, 'compare_at_price': None, 'sku': '1055', 'weight_unit': 'lb', 'weight': 0, 'inventory_management': 'shopify', 'inventory_policy': 'continue'}], 'status': 'draft'}}"  https://${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products.json
# shopify update product
curl --header "X-Shopify-Access-Token: ${SHOPIFY_AUTH_TOKEN}" --request PUT "https://${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products/${PRODUCT_ID}.json" \
--header 'Content-Type: application/json' \
--data-binary '@product.json'
# delete product by id
curl --location --header "X-Shopify-Access-Token: ${SHOPIFY_AUTH_TOKEN}"  -X DELETE "https://${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products/$1.json"
# remove variant, delete variant in "standard product" (has only one variant )  leads to remove product
curl --location -w "response-code: %{http_code}\n" -X DELETE "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products/${PRODUCT_ID}/variants/${VARIANT_ID}.json"

# add metadata to image 
curl --location -X PUT "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products/${PRODUCT_ID}/images/${IMAGE_ID}.json"  \
--header 'Content-Type: application/json' \
--data-raw '{"image": {"id": 28125015310400,"metafields": [{"key": "test2","value": "test3","value_type": "string","namespace": "tags", "imageid":28125015310400}]}}'
# get image count by product
curl --location -X GET "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products/${PRODUCT_ID}/images/count.json" | jq .
# get images by product
curl --location -X GET "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/products/${PRODUCT_ID}/images.json" | jq .
# get image metadata from !!! global account storage !!!
curl --location -X GET https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/metafields.json?metafield[imageid]=${IMAGE_ID}

# get all collections
curl --location -X GET "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/smart_collections.json" | jq .
# get collection by id 
COLLECTION_ID=270289993909
curl --location -X GET "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/smart_collections/{$COLLECTION_ID}.json" | jq .
# delete collection by id 
curl --location -X DELETE "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/smart_collections/{$COLLECTION_ID}.json" | jq .

# get policies
curl --location --request GET "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/policies.json"
# get policies with token
curl --location --header "X-Shopify-Access-Token: ${SHOPIFY_AUTH_TOKEN}" --request GET "https://${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/policies.json"
# get access scopes
curl --location --request GET "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/oauth/access_scopes.json" | jq .
# get shop description 
curl --location --request GET "https://${SHOPIFY_API_KEY}:${SHOPIFY_API_PASSWORD}@${SHOPIFY_SHOP_NAME}.myshopify.com/admin/api/2021-04/shop.json" --silent | jq .