Skip to content

Instantly share code, notes, and snippets.

View Johnetordoff's full-sized avatar

John Tordoff Johnetordoff

View GitHub Profile
@Johnetordoff
Johnetordoff / gist:e13cc582ac78616b2382d5e51e25d9eb
Created June 26, 2024 17:58
preprint institution relationship payload
{
"data": [
{
"type": "institutions",
"id": "<institution_id>"
}
]
}
@Johnetordoff
Johnetordoff / gist:75f33c1db59cfb5c86c49061dcbcafa7
Created June 25, 2024 14:21
PreprintInstitution Get Response
{
"data":[
{
"id":"667ad190c7ea910017f88d59",
"type":"institutions",
"attributes":{
"name":"Waters LLC",
"description":"",
"iri":"https://nicholson.com/",
"ror_iri":"https://nixon.com/",
**GET v2/preprints/(?P<preprint_id>\w+)/institutions/$**
----
Returns all institutional affiliations available on a Preprint.
* **URL Params**
TBD filter/sort params?
* **Data Params**
None
[2024-05-30 17:30:21,851: INFO/MainProcess] sync with celery@878df8371eaa
[2024-05-30 17:30:21,969: ERROR/MainProcess] Received unregistered task of type 'addon_service.listeners.listen_to_queue_route'.
The message has been ignored and discarded.
Did you remember to import the module containing this task?
Or maybe you're using relative imports?
Please see
http://docs.celeryq.org/en/latest/internals/protocol.html
for more information.
def check_access(node, auth, action, cas_resp):
"""Verify that user can perform requested action on resource. Raise appropriate
error code if action cannot proceed.
"""
permission = permission_map.get(action, None)
if permission is None:
raise HTTPError(http_status.HTTP_400_BAD_REQUEST)
# Permissions for DraftNode should be based upon the draft registration
if isinstance(node, DraftNode):
Traceback (most recent call last):
File "/usr/local/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.12/threading.py", line 1010, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.12/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.12/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "/usr/local/lib/python3.12/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
from flask import Flask, request, redirect, session
import requests
import uuid
app = Flask(__name__)
app.secret_key = 'your_secret_key' # Needed for session management
# Register with the oauth provider and change the credentials to match.
CLIENT_ID = '<change>'
CLIENT_SECRET = '<change>'
@Johnetordoff
Johnetordoff / Oauth Provider
Created February 20, 2024 14:35
Oauth Provider
from flask import Flask, request, jsonify, redirect, render_template_string
from uuid import uuid4
app = Flask(__name__)
# In-memory database simulation
clients = {} # Registered clients {client_id: client_secret}
auth_codes = {} # Authorization codes {code: client_id}
tokens = {} # Tokens {access_token: client_id}
from rest_framework import (
exceptions,
permissions,
)
from addon_service.models import (
ResourceReference,
UserReference,
)
from app.authentication import authenticate_resource
2023-02-28T14:22:37.3827537Z Requested labels: ubuntu-20.04
2023-02-28T14:22:37.3827583Z Job defined at: CenterForOpenScience/osf.io/.github/workflows/test-build.yml@refs/pull/10269/merge
2023-02-28T14:22:37.3827615Z Waiting for a runner to pick up this job...
2023-02-28T14:22:39.8596453Z Job is waiting for a hosted runner to come online.
2023-02-28T14:22:41.1245961Z Job is about to start running on the hosted runner: GitHub Actions 2 (hosted)
2023-02-28T14:22:44.8885383Z Current runner version: '2.301.1'
2023-02-28T14:22:44.8920042Z ##[group]Operating System
2023-02-28T14:22:44.8920749Z Ubuntu
2023-02-28T14:22:44.8921206Z 20.04.5
2023-02-28T14:22:44.8921521Z LTS