Skip to content

Question about Python script for generating GitHub App JWT and unrelated documentation fragments #44496

@mjh10brooke-max

Description

@mjh10brooke-max

Script for Generating GitHub App JWT and Additional azd CLI Documentation Fragments

This issue documents a Python script for generating a GitHub App JWT using a private PEM file, as well as some additional, possibly unintended, fragments of azd CLI documentation and other unrelated notes.

Python3 Script to Generate GitHub App JWT

#!/usr/bin/env python3
import sys
import time
import jwt

# Get PEM file path
if len(sys.argv) > 1:
    pem = sys.argv[1]
else:
    pem = input("Enter path of private PEM file: ")

# Get the Client ID
if len(sys.argv) > 2:
    client_id = sys.argv[2]
else:
    client_id = input("Enter your Client ID: ")

# Open PEM
with open(pem, 'rb') as pem_file:
    signing_key = pem_file.read()

payload = {
    # Issued at time
    'iat': int(time.time()),
    # JWT expiration time (10 minutes maximum)
    'exp': int(time.time()) + 600,
    # GitHub App's client ID
    'iss': client_id
}

# Create JWT
encoded_jwt = jwt.encode(payload, signing_key, algorithm='RS256')

print(f"JWT: {encoded_jwt}")

Additional Context

  • The message contained multiple fragments of azd CLI documentation and Takeout details that appear unrelated to this script and issue.
  • Please clarify if the intent is to cleanly document the JWT script, request an enhancement (e.g., support for more flags or error handling), or report a bug.

Questions

  • Is there a bug or enhancement request related to the JWT script?
  • Should the extraneous documentation and notes be cataloged or excluded?

Labels: question, script

Metadata

Metadata

Assignees

No one assigned

    Labels

    customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-author-feedbackWorkflow: More information is needed from author to address the issue.no-recent-activityThere has been no recent activity on this issue.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions