-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add configuration file support for API key management #1
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| 74F3B7C12E1CF4F400C544D1 /* AudioProcess.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F3B7C02E1CF4F400C544D1 /* AudioProcess.swift */; }; | ||
| 74F860942E29A9D20007163C /* ProcessTapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F860932E29A9D20007163C /* ProcessTapper.swift */; }; | ||
| 74F860962E2B19060007163C /* CoreAudioUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F860952E2B19060007163C /* CoreAudioUtils.swift */; }; | ||
| AD7653122E43104600DF15D1 /* config.json in Resources */ = {isa = PBXBuildFile; fileRef = AD7653112E43104600DF15D1 /* config.json */; }; | ||
| /* End PBXBuildFile section */ | ||
|
|
||
| /* Begin PBXCopyFilesBuildPhase section */ | ||
|
|
@@ -79,6 +80,7 @@ | |
| 74F3B7C02E1CF4F400C544D1 /* AudioProcess.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioProcess.swift; sourceTree = "<group>"; }; | ||
| 74F860932E29A9D20007163C /* ProcessTapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProcessTapper.swift; sourceTree = "<group>"; }; | ||
| 74F860952E2B19060007163C /* CoreAudioUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreAudioUtils.swift; sourceTree = "<group>"; }; | ||
| AD7653112E43104600DF15D1 /* config.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = config.json; sourceTree = "<group>"; }; | ||
| /* End PBXFileReference section */ | ||
|
|
||
| /* Begin PBXFrameworksBuildPhase section */ | ||
|
|
@@ -121,6 +123,7 @@ | |
| 1677AFD72B576375008C61C0 /* Resources */ = { | ||
| isa = PBXGroup; | ||
| children = ( | ||
| AD7653112E43104600DF15D1 /* config.json */, | ||
| 1677AFE02B57678E008C61C0 /* Assets.xcassets */, | ||
| 1677AFA92B57618A008C61C0 /* Playground.entitlements */, | ||
| ); | ||
|
|
@@ -270,6 +273,7 @@ | |
| buildActionMask = 2147483647; | ||
| files = ( | ||
| 1677AFC42B57618A008C61C0 /* Preview Assets.xcassets in Resources */, | ||
| AD7653122E43104600DF15D1 /* config.json in Resources */, | ||
| 7469F1FA2E3AC3D00090AEBA /* README.md in Resources */, | ||
| 1677AFE12B57678E008C61C0 /* Assets.xcassets in Resources */, | ||
| ); | ||
|
|
@@ -438,7 +442,7 @@ | |
| DEAD_CODE_STRIPPING = YES; | ||
| DEPLOYMENT_POSTPROCESSING = NO; | ||
| DEVELOPMENT_ASSET_PATHS = "\"Playground/Preview Content\""; | ||
| DEVELOPMENT_TEAM = ""; | ||
| DEVELOPMENT_TEAM = 2A7SXV3WJH; | ||
| ENABLE_HARDENED_RUNTIME = YES; | ||
| ENABLE_PREVIEWS = YES; | ||
| EXCLUDED_SOURCE_FILE_NAMES = "GoogleService-Info.plist"; | ||
|
|
@@ -465,6 +469,7 @@ | |
| MACOSX_DEPLOYMENT_TARGET = 14.2; | ||
| MARKETING_VERSION = 0.0.1; | ||
| PRODUCT_BUNDLE_IDENTIFIER = "com.argmaxinc.example.Playground${DEVELOPMENT_TEAM}"; | ||
| "PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = com.argmaxinc.example.Playground; | ||
| PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| PROVISIONING_PROFILE_SPECIFIER = ""; | ||
| SDKROOT = auto; | ||
|
|
@@ -490,7 +495,7 @@ | |
| DEAD_CODE_STRIPPING = YES; | ||
| DEPLOYMENT_POSTPROCESSING = NO; | ||
| DEVELOPMENT_ASSET_PATHS = "\"Playground/Preview Content\""; | ||
| DEVELOPMENT_TEAM = ""; | ||
| DEVELOPMENT_TEAM = 2A7SXV3WJH; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove your development team :) |
||
| ENABLE_HARDENED_RUNTIME = YES; | ||
| ENABLE_PREVIEWS = YES; | ||
| EXCLUDED_SOURCE_FILE_NAMES = "GoogleService-Info-Dev.plist"; | ||
|
|
@@ -517,6 +522,7 @@ | |
| MACOSX_DEPLOYMENT_TARGET = 14.2; | ||
| MARKETING_VERSION = 0.0.1; | ||
| PRODUCT_BUNDLE_IDENTIFIER = "com.argmaxinc.example.Playground${DEVELOPMENT_TEAM}"; | ||
| "PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = com.argmaxinc.example.Playground; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| PROVISIONING_PROFILE_SPECIFIER = ""; | ||
| SDKROOT = auto; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "apiKey": "YOUR_API_KEY_HERE", | ||
| "huggingFaceToken": null | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,17 +33,28 @@ In Xcode, select your app target and go to **Signing & Capabilities**. Choose yo | |
| ### 2. Add Your API Key | ||
| In order to unlock the SDK, you will need to provide your API key. You can create one at [https://app.argmaxinc.com](https://app.argmaxinc.com). | ||
|
|
||
| In `DefaultEnvInitializer.swift`, update the following code with your credentials: | ||
| #### Option 1: Using Configuration File (Recommended) | ||
| 1. Copy the template configuration file: | ||
| ```bash | ||
| cp Playground/Resources/config.template.json Playground/Resources/config.json | ||
| ``` | ||
| 2. Edit `Playground/Resources/config.json` and replace `YOUR_API_KEY_HERE` with your actual API key: | ||
| ```json | ||
| { | ||
| "apiKey": "your_actual_api_key_here", | ||
| "huggingFaceToken": null | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we just open sourced our huggingface repo, so huggingfacetoken is no longer needded, we can remove this field
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea I also removed huggingFaceToken form the PlainTextAPIKeyProvider now |
||
| } | ||
| ``` | ||
|
|
||
| The `config.json` file is already added to `.gitignore` to prevent accidentally committing your API key. | ||
|
|
||
| #### Option 2: Direct Code Modification | ||
| Alternatively, you can modify the fallback API key in `DefaultEnvInitializer.swift`: | ||
|
|
||
| ```swift | ||
| public class DefaultEnvInitializer: PlaygroundEnvInitializer { | ||
|
|
||
| public func createAPIKeyProvider() -> APIKeyProvider { | ||
| return PlainTextAPIKeyProvider( | ||
| apiKey: "", // TODO: Add your Argmax SDK API key | ||
| ) | ||
| } | ||
| } | ||
| return PlainTextAPIKeyProvider( | ||
| apiKey: "your_api_key_here" // Fallback API key | ||
| ) | ||
| ``` | ||
|
|
||
| > **Do not commit your API key.**. | ||
| > **Important**: Never commit your actual API key to version control. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, Xcode generated this part