This repository was archived by the owner on Mar 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Add support for user credentials/jwt #5
Merged
+3,960
−2,835
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
env.sh | ||
.nyc_output | ||
coverage | ||
.tern-port |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,14 +14,13 @@ Wrapper library for Topcoder Submission API | |
|
||
```javascript | ||
const submissionApi = require('topcoder-submission-api-wrapper') | ||
const submissionApiClient = submissionApi(_.pick(config, | ||
const submissionApiM2MClient = submissionApi(_.pick(config, | ||
['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME', | ||
'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET', 'SUBMISSION_API_URL', | ||
'AUTH0_PROXY_SERVER_URL'])) | ||
``` | ||
|
||
**Configuration / Environment variables:** | ||
|
||
**M2M Authentication Configuration:** | ||
- AUTH0_URL - the auth0 url | ||
- AUTH0_AUDIENCE - the auth0 audience | ||
- TOKEN_CACHE_TIME - (optional) the token cache time | ||
|
@@ -33,6 +32,29 @@ Wrapper library for Topcoder Submission API | |
- PER_PAGE - the page size | ||
- MAX_PAGE_SIZE - the max number of page size | ||
|
||
```javascript | ||
const submissionApiUserCredentialsClient = submissionApi(_.pick(config, | ||
['USERNAME', 'PASSWORD', 'TC_AUTHN_URL', 'TC_AUTHZ_URL', 'TC_CLIENT_ID', | ||
'TC_CLIENT_V2CONNECTION', 'SUBMISSION_API_URL'])) | ||
``` | ||
|
||
**User Credentials Authentication Configuration:** | ||
- USERNAME - Topcoder handle | ||
- PASSWORD - Topcoder password | ||
- TC_AUTHN_URL - OAUTH2 token URL, e.g. `https://topcoder.auth0.com/oauth/ro` or for dev `https://topcoder-dev.auth0.com/oauth/ro` | ||
- TC_AUTHZ_URL - Topcoder API token URL, e.g. `https://api.topcoder.com/v3/authorizations` or for dev `https://api.topcoder-dev.com/v3/authorizations` | ||
- TC_CLIENT_ID - OAUTH2 Client ID, e.g. `6ZwZEUo2ZK4c50aLPpgupeg5v2Ffxp9P` or for dev `JFDo7HMkf0q2CkVFHojy3zHWafziprhT` | ||
- TC_CLIENT_V2CONNECTION - The OAUTH2 Client data source, e.g. `TC-User-Database` | ||
callmekatootie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- SUBMISSION_API_URL - Topcoder V5 Submission API URL. E.g. `https://api.topcoder.com/v5` or for dev `https://api.topcoder-dev.com/v5` | ||
|
||
```javascript | ||
const submissionJwtMethodArgClient = submissionApi(_.pick(config, | ||
['SUBMISSION_API_URL'])) | ||
``` | ||
|
||
**JWT Method Argument Authentication Configuration:** | ||
- SUBMISSION_API_URL - Topcoder V5 Submission API URL. E.g. `https://api.topcoder.com/v5` or for dev `https://api.topcoder-dev.com/v5` | ||
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. Comment: So the JWT way is to only pass the submission api url and then pass the token each time any method is called? 🤔 hmm... Not sure why the constructor didn't accept the jwt token itself... assuming it is because it allows us to use different tokens for each method... |
||
|
||
3. Every function in this wrapper will return a promise, Handling promises is at the caller end. Call the functions with appropriate arguments | ||
|
||
E.g. | ||
|
@@ -126,6 +148,13 @@ Following environment variables need to be set up before running the tests | |
- TEST_AUTH0_CLIENT_ID | ||
- TEST_AUTH0_CLIENT_SECRET | ||
- TEST_SUBMISSION_API_URL | ||
- TEST_JWT | ||
callmekatootie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- TEST_USERNAME | ||
- TEST_PASSWORD | ||
- TEST_TC_AUTHN_URL | ||
- TEST_TC_AUTHZ_URL | ||
- TEST_TC_CLIENT_ID | ||
- TEST_TC_CLIENT_V2CONNECTION | ||
``` | ||
|
||
Refer to Step # 2 in [this section](#how-to-use-this-wrapper) to learn more about the configuration variables. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.