/oauth-samples

OAuth2 samples scripts for Segment services

Primary LanguageShellMIT LicenseMIT

oauth-samples

This repository contains samples scripts to help get started with the OAuth authentication for Segment APIs.

Shell Examples

Shell script examples can be found in shell directory. These scripts are written in bash and can be run in any bash environment.

  1. Create Private/Public Key Pair

Creates a private and public key pair using openssl. The private key is used to sign the JWT and the public key is used to verify the JWT. The private key is secured with the client and the public key is uploaded while creating Segment OAuth application.

./create-keypair.sh -s sample
  1. Generate Access Token

Generates a JWT access token using the private key for the OAuth app id created in Segment UI and associated with public key id.

./generate-access-token.sh -a 2c3y07DGjEFeTIchtLQaFZ9NDCf -i 2c4EEVxBkmVyJcNsvbapt846Qik -k private-sample.pem -h https://oauth2.segment.io -v on
  1. Send Request to Tracking API

Sends a request to the Segment Tracking API using the generated access token.

./send-tapi-request.sh -w <write-key> -j <access-jwt-token> -h https://api.segment.io -o on
  1. Decode JWT Token

Decodes JWT token.

./decode-jwt.sh -j <jwt-token>