Authentication overview

Authentication for the Open Science Framework (OSF) encompasses both user interface access and programmatic interaction via its API. User authentication primarily secures access to the OSF web platform for managing projects, collaborating with researchers, and accessing registered studies. The OSF API, designed for developers and technical users, allows for automated tasks such as uploading files, managing project components, and retrieving metadata programmatically. This dual approach ensures that both human users and automated scripts can securely interact with the platform while maintaining data integrity and access control.

The OSF's authentication mechanisms are foundational to its mission of promoting open, reproducible science by regulating who can view, modify, or publish research materials. For direct user access, the OSF implements standard web authentication flows, including email and password, and integrates with various institutional and third-party identity providers. For API interactions, the OSF relies on Personal Access Tokens (PATs), which serve as long-lived, revocable credentials tied to a user account. These tokens grant granular control over API permissions, allowing users to define the scope of access for specific applications or scripts. The OSF documentation provides detailed instructions for setting up and managing these authentication methods, emphasizing security and responsible access to scientific data and resources.

Supported authentication methods

The Open Science Framework supports several authentication methods tailored for different use cases, from individual researchers accessing the web interface to developers building integrations with the OSF API. These methods are designed to provide flexibility while maintaining a secure environment for scientific collaboration and data management.

User Interface Authentication

  • Email and Password: The default method for individual users to create and access their OSF accounts. This involves a standard registration process and login with a unique email address and a user-defined password. Users are encouraged to use strong, unique passwords.
  • Institutional Single Sign-On (SSO): OSF integrates with various institutional identity providers, allowing users affiliated with partner institutions to log in using their existing institutional credentials. This method streamlines access and often leverages institutional multi-factor authentication policies. OSF Institutions offers tailored SSO solutions.
  • Third-Party Integrations: OSF supports authentication through select third-party services, enabling users to log in using credentials from platforms like ORCID, which provides persistent digital identifiers for researchers. This helps simplify account management and link research outputs to a researcher's professional profile.

API Authentication

  • Personal Access Tokens (PATs): For programmatic access to the OSF API, users generate Personal Access Tokens (PATs) from their OSF account settings. These tokens are alphanumeric strings that act as a substitute for a username and password for API requests. PATs are associated with specific user accounts and inherit the permissions of that account. Users can define the scope of access for each PAT, limiting its capabilities to specific actions (e.g., read-only access, project management). PATs are essential for developing applications, scripts, or integrations that interact with OSF data and services. The OSF API is documented to guide developers on proper PAT usage.

Summary of Authentication Methods

Method When to Use Security Level
Email and Password Individual user login to OSF web interface. Standard (enhanced by strong password practices and MFA).
Institutional SSO Users affiliated with OSF partner institutions for web interface access. High (leverages institutional security policies, often including MFA).
Third-Party (e.g., ORCID) Web interface login, linking OSF account to external researcher profiles. Standard (dependent on the third-party provider's security).
Personal Access Tokens (PATs) Programmatic access to OSF API for scripts, applications, and integrations. High (requires careful management, scope definition, and secure storage).

Getting your credentials

Accessing the Open Science Framework, whether through its web interface or API, requires obtaining the appropriate credentials. The process varies based on the authentication method you intend to use.

For User Interface Access (Email/Password)

  1. Registration: Navigate to the OSF registration page.
  2. Provide Information: Enter your full name, email address, and create a strong, unique password.
  3. Email Verification: Follow the instructions in the verification email sent to your registered address to activate your account.
  4. Login: Once verified, you can log in to OSF using your email and password.

For User Interface Access (Institutional SSO or Third-Party)

  1. Login Page: Go to the OSF login page.
  2. Select Provider: Look for options like "Login through your institution" or specific third-party service buttons (e.g., ORCID).
  3. Redirect and Authenticate: You will be redirected to your institution's or the third-party service's login portal. Authenticate using your credentials for that service.
  4. Consent (if applicable): You may be prompted to grant OSF permission to access basic profile information from the external provider.

For API Access (Personal Access Tokens - PATs)

Personal Access Tokens are generated directly from your OSF user account settings. This process assumes you already have an active OSF account.

  1. Log in to OSF: Access your OSF account via the web interface.
  2. Navigate to User Settings: Click on your profile picture or name in the top right corner and select "Settings" or "Account Settings."
  3. Find Personal Access Tokens: Within your settings, locate the "Personal Access Tokens" section.
  4. Generate New Token: Click the button to generate a new token. You will be prompted to:
    • Provide a description: A clear, descriptive name for the token (e.g., "My Python Script for Project X").
    • Define Scopes: Select the specific permissions you want to grant the token. This is crucial for security, as it limits what the token can do. Examples of scopes include osf.full_read, osf.full_write, osf.files_read, etc. Grant only the minimum necessary permissions.
  5. Save Token: Once generated, the token string will be displayed. Copy this token immediately and store it securely. For security reasons, the token will only be shown once and cannot be retrieved later. If lost, you must revoke it and generate a new one.
  6. Revoke Tokens: You can manage and revoke existing PATs from the same Personal Access Tokens section in your settings at any time.

Authenticated request example

When making API requests to the Open Science Framework using a Personal Access Token (PAT), you typically include the token in the Authorization header of your HTTP request. The OSF API follows a RESTful design, and examples are often provided in Python or Curl. For this example, we'll demonstrate fetching information about a public project using a PAT.

Assume you have an OSF project ID (e.g., "abcdef") and a generated PAT (e.g., "your_personal_access_token").

Using curl (Command Line)

curl -H "Authorization: Bearer your_personal_access_token" \
     https://api.osf.io/v2/nodes/abcdef/

Explanation:

  • -H "Authorization: Bearer your_personal_access_token": This sets the HTTP Authorization header. The value uses the Bearer scheme, followed by your actual Personal Access Token. This is the standard way to pass OAuth 2.0-style access tokens. RFC 6750 describes the Bearer Token usage in detail.
  • https://api.osf.io/v2/nodes/abcdef/: This is the OSF API endpoint for a specific project (referred to as a "node" in the OSF API). Replace abcdef with your actual project ID.

Using Python with the requests library

import requests

OSF_API_BASE = "https://api.osf.io/v2"
PROJECT_ID = "abcdef"  # Replace with your OSF project ID
PERSONAL_ACCESS_TOKEN = "your_personal_access_token"  # Replace with your actual PAT

headers = {
    "Authorization": f"Bearer {PERSONAL_ACCESS_TOKEN}"
}

# Construct the API endpoint URL for a specific project
url = f"{OSF_API_BASE}/nodes/{PROJECT_ID}/"

try:
    response = requests.get(url, headers=headers)
    response.raise_for_status()  # Raise an HTTPError for bad responses (4xx or 5xx)

    project_data = response.json()
    print("Successfully retrieved project data:")
    print(project_data.get("data", {}).get("attributes", {}).get("title"))
    # You can process other fields from project_data here

except requests.exceptions.HTTPError as err:
    print(f"HTTP error occurred: {err}")
    print(f"Response content: {err.response.text}")
except requests.exceptions.RequestException as err:
    print(f"An error occurred: {err}")

Explanation:

  • The requests.get() function is used to send an HTTP GET request to the specified URL.
  • The headers dictionary contains the Authorization header, formatted as "Bearer <your_pat>".
  • response.raise_for_status() checks if the request was successful; otherwise, it raises an exception.
  • response.json() parses the JSON response body into a Python dictionary.

This example demonstrates how to make a basic authenticated request. For operations that modify data (e.g., POST, PUT, DELETE), you would use the appropriate HTTP method and ensure your PAT has the necessary write scopes.

Security best practices

Adhering to security best practices for Open Science Framework authentication is crucial for protecting research data, maintaining project integrity, and ensuring compliance with data protection regulations like GDPR. Both individual users and API developers should implement these guidelines.

For All Users (Web Interface & API)

  • Strong, Unique Passwords: Always use complex and unique passwords for your OSF account. Avoid reusing passwords from other services. Consider using a password manager to generate and store strong credentials.
  • Enable Multi-Factor Authentication (MFA): Where available (check your OSF account settings), enable MFA. This adds an extra layer of security by requiring a second verification method (e.g., a code from a mobile app or SMS) in addition to your password.
  • Regularly Review Account Activity: Periodically check your OSF account settings for any unfamiliar activity or unauthorized access attempts. Report suspicious activity to OSF support immediately.
  • Keep Software Updated: Ensure your operating system, web browser, and any client-side software used to access OSF are kept up-to-date. Software updates often include security patches that protect against known vulnerabilities.
  • Phishing Awareness: Be wary of suspicious emails or messages claiming to be from OSF. Always verify the sender and the legitimacy of links before clicking or entering credentials. Only log in through the official OSF website.

For API Users (Personal Access Tokens - PATs)

  • Principle of Least Privilege: When generating Personal Access Tokens, grant only the minimum necessary scopes (permissions) required for the specific task or application. For example, if a script only needs to read project data, do not grant it write access. This limits the potential damage if a token is compromised.
  • Secure Storage of PATs: Never hardcode PATs directly into public code repositories or plain text files. Store them securely using environment variables, dedicated secrets management services, or secure configuration files that are not committed to version control.
  • Token Revocation: Regularly review your active PATs in your OSF account settings. Revoke any tokens that are no longer needed, have expired, or are suspected of being compromised. This is a critical step in managing API security.
  • Short-Lived Tokens (where applicable): While OSF PATs are long-lived, if your workflow allows, consider generating new tokens for specific, short-term tasks and revoking them once the task is complete. This reduces the window of opportunity for a token to be exploited.
  • Monitor API Usage: If OSF provides API usage logs or audit trails, monitor them for unusual patterns or unauthorized access attempts.
  • Secure Development Practices: When developing applications that use the OSF API, follow secure coding guidelines to prevent common vulnerabilities like injection attacks, improper error handling, and sensitive data exposure. For general guidance on API security, consult resources like the API security best practices from Kong.