Skip to content

Commit

Permalink
Merge pull request #148 from desci-labs/orcid-api
Browse files Browse the repository at this point in the history
Orcid api
  • Loading branch information
hubsmoke authored Oct 23, 2023
2 parents a1941ee + b364858 commit 3bcda72
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@ DISCORD_NOTIFICATIONS_WEBHOOK_URL=

# for sending nodes cover cid to media servers
# must match value in nodes-media/.env
MEDIA_SECRET_KEY=supersecret
MEDIA_SECRET_KEY=supersecret

ORCID_API_DOMAIN=https://api.sandbox.orcid.org
ORCID_CLIENT_ID=
ORCID_CLIENT_SECRET=
2 changes: 2 additions & 0 deletions .github/workflows/build-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ jobs:
- name: Verify EKS Deployment (DEV)
if: github.ref == 'refs/heads/develop'
run: |
kubectl apply -f desci-server/kubernetes/deployment_dev.yaml
kubectl rollout status deployment/desci-server-dev
- name: Verify EKS Deployment (DEMO)
Expand All @@ -205,4 +206,5 @@ jobs:
- name: Verify EKS Deployment (PROD)
if: github.ref == 'refs/heads/main'
run: |
kubectl apply -f desci-server/kubernetes/deployment.yaml
kubectl rollout status deployment/desci-server
5 changes: 3 additions & 2 deletions desci-server/kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ metadata:
labels:
App: DesciServer
spec:
replicas: 16
revisionHistoryLimit: 2
replicas: 12
revisionHistoryLimit: 8
selector:
matchLabels:
App: DesciServer
Expand Down Expand Up @@ -39,6 +39,7 @@ spec:
export JWT_SECRET={{ .Data.JWT_SECRET }}
export JWT_EXPIRATION=15m
export SESSION_KEY={{ .Data.SESSION_KEY }}
export ORCID_API_DOMAIN={{ .Data.ORCID_API_DOMAIN }}
export ORCID_CLIENT_ID={{ .Data.ORCID_CLIENT_ID }}
export ORCID_CLIENT_SECRET={{ .Data.ORCID_CLIENT_SECRET }}
export ARWEAVE_ENABLED=0
Expand Down
3 changes: 2 additions & 1 deletion desci-server/kubernetes/deployment_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
App: DesciServerDev
spec:
replicas: 6
revisionHistoryLimit: 2
revisionHistoryLimit: 8
selector:
matchLabels:
App: DesciServerDev
Expand Down Expand Up @@ -39,6 +39,7 @@ spec:
export JWT_SECRET={{ .Data.JWT_SECRET }}
export JWT_EXPIRATION=15m
export SESSION_KEY={{ .Data.SESSION_KEY }}
export ORCID_API_DOMAIN={{ .Data.ORCID_API_DOMAIN }}
export ORCID_CLIENT_ID={{ .Data.ORCID_CLIENT_ID }}
export ORCID_CLIENT_SECRET={{ .Data.ORCID_CLIENT_SECRET }}
export ARWEAVE_ENABLED=0
Expand Down
9 changes: 6 additions & 3 deletions desci-server/src/controllers/auth/orcid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const orcidAuthClose = async (req: Request, res: Response) => {
export const validateOrcid = async (req: Request, res: Response) => {
// console.log('TOK', req.query.token);
try {
const url = `https://pub.sandbox.orcid.org/v3.0/${req.query.orcid}/record`;
const url = `https://api.${process.env.ORCID_API_DOMAIN}/v3.0/${req.query.orcid}/record`;
const { data } = await axios.get(url, {
headers: { Authorization: `Bearer ${req.query.token}`, 'Content-Type': 'application/json', Accept: '*/*' },
});
Expand Down Expand Up @@ -57,9 +57,12 @@ export interface OrcIdRecordData {
};
}
export const getOrcidRecord = async (orcid: string, accessToken: string): Promise<OrcIdRecordData> => {
/**
* this will fail if the orcid doesn't match the accessToken
*/
const config: AxiosRequestConfig = {
method: 'get',
url: `https://pub.sandbox.orcid.org/v3.0/${orcid}/record`,
url: `https://api.${process.env.ORCID_API_DOMAIN}/v3.0/${orcid}/record`,
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
Expand Down Expand Up @@ -88,7 +91,7 @@ const getAllOrcData = async ({ queryCode, redirectUri }: { queryCode: string; re
access_token: string;
refresh_token: string;
expires_in: number;
}>('https://sandbox.orcid.org/oauth/token', data, {
}>(`https://${process.env.ORCID_API_DOMAIN}/oauth/token`, data, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
Expand Down

0 comments on commit 3bcda72

Please sign in to comment.