Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spaceship] Support individual API key #21987

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

manicmaniac
Copy link

@manicmaniac manicmaniac commented Apr 22, 2024

Checklist

  • I've run bundle exec rspec from the root directory to see all new and existing tests pass
  • I've followed the fastlane code style and run bundle exec rubocop -a to ensure the code style is valid
  • I see several green ci/circleci builds in the "All checks have passed" section of my PR (connect CircleCI to GitHub if not)
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary.
  • I've added or updated relevant unit tests.

Motivation and Context

Resolves #21959

Description

The main difference between a team API key and an individual API key is that the latter does not have issuer_id.

So I made issuer_id optional and if it does not exist, fastlane treats the key as an individual API key.

Since the JWT token payload of an individual API key is a bit different from a team API key, I changed the logic to generate token with following the official document.

https://developer.apple.com/documentation/appstoreconnectapi/generating_tokens_for_api_requests#4313913

Testing Steps

Sorry, I don't have a good idea to test whether if the generated JWT payload is valid or not, without exposing my individual API key.

However I tested it by writing a small lane like the following.

# fastlane/Fastfile
lane :test do
  app_store_connect_api_key(
    key_id: ENV.fetch('INDIVIDUAL_API_KEY_ID'),
    key_content: ENV.fetch('INDIVIDUAL_API_KEY_CONTENT_BASE64'),
    is_key_content_base64: true,
    in_house: false,
    duration: 500
  )
  puts Spaceship::ConnectAPI::App.all
end

and confirmed that it works well in my private repo.

@manicmaniac manicmaniac marked this pull request as ready for review April 22, 2024 12:14
@manicmaniac manicmaniac changed the title Support individual API key [spaceship] Support individual API key Apr 22, 2024
@lucgrabowski
Copy link
Contributor

lucgrabowski commented Apr 23, 2024

Thank you for your contribution :)) 💪
The code looks good to me 🔥, I'll add a comment with an idea for a test in spec.

Copy link
Contributor

@lucgrabowski lucgrabowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contribution and adding tests :)

@anasyarn
Copy link

Please merge this as soon as possible, waiting for this change for a long!!!

@anasyarn
Copy link

Please merge @manicmaniac

@manicmaniac
Copy link
Author

@anasyarn Sorry I don't have the permission to do it, just wait for the fastlane team's reaction. Or you can use my fork until then.

@max-ott
Copy link
Contributor

max-ott commented May 3, 2024

@anasyarn Did you test this? Would love to merge this, but as it's a rather "big" change, we need to ensure enough people from the community tested it.

@anasyarn
Copy link

anasyarn commented May 3, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Individual API Key not supported
4 participants