Authentication overview

Freelancer, as an online talent platform, employs distinct authentication mechanisms for its web interface and its API. For direct user interaction through the website, a traditional session-based authentication model is used. This involves users providing login credentials (email/username and password), after which a session token is issued and managed by the browser, allowing access to authenticated areas of the platform. This approach is standard for web applications and is reinforced with measures such as two-factor authentication (2FA) to enhance account security.

For programmatic access and integrations, Freelancer provides an API that utilizes OAuth 2.0 for authorization. OAuth 2.0 is an industry-standard protocol for authorization that allows third-party applications to obtain limited access to a user's resources on an HTTP service, without exposing the user's password. This model separates the roles of resource owner (the user), client (the integrating application), and authorization server (Freelancer's API), enabling secure delegation of access. The API supports various OAuth 2.0 grant types, depending on the application's nature and the level of access required. Understanding the specific grant type applicable to your integration is crucial for secure and functional API access.

All communication with Freelancer's servers, both for web and API interactions, is encrypted using Transport Layer Security (TLS), ensuring that data transmitted between the client and server remains confidential and protected from interception. This is a fundamental security practice for any online service handling sensitive user and transaction data.

Supported authentication methods

Freelancer supports a range of authentication methods tailored to different user and integration needs. The choice of method depends on whether the interaction is directly through the user interface or programmatically via the API.

Method When to Use Security Level
Email/Password (Session-based) Direct user login to the Freelancer website or mobile apps. Standard. Enhanced with strong password policies and 2FA.
Two-Factor Authentication (2FA) Optional security layer for user logins. Used in conjunction with email/password. High. Adds an extra layer of verification, typically via SMS code or authenticator app.
OAuth 2.0 (Client Credentials Grant) Server-to-server applications needing to access Freelancer's API to manage their own resources (e.g., listing projects, managing bids). No user context is required. High. Requires secure handling of client ID and client secret.
OAuth 2.0 (Authorization Code Grant) Web applications or mobile apps acting on behalf of a Freelancer user. Requires explicit user consent. High. Redirect-based, tokens exchanged securely, user consent managed.
OAuth 2.0 (Implicit Grant) Single-page applications (SPAs) or mobile apps where the client secret cannot be securely stored. Deprecated in favor of Authorization Code with PKCE. Moderate. Tokens are returned directly in the URL fragment; less secure than Authorization Code. Use with caution.

For most API integrations, the Client Credentials Grant is suitable for applications that operate independently of a specific user. When user-specific actions are required, the Authorization Code Grant is the recommended and most secure OAuth 2.0 flow, especially when combined with Proof Key for Code Exchange (PKCE) for public clients like mobile or single-page applications.

Getting your credentials

To integrate with the Freelancer API, you will need to obtain API credentials. This typically involves registering your application within Freelancer's developer portal. The process generally follows these steps:

  1. Create a Freelancer Account: If you don't already have one, create a standard Freelancer user account, which will serve as your developer account.
  2. Access the Developer Portal: Navigate to the Freelancer API documentation and developer portal. This portal provides resources for API usage, including guides on authentication and endpoint references.
  3. Register Your Application: Within the developer portal, locate the section for registering new applications. You will typically be asked to provide details such as:
    • Application Name: A descriptive name for your integration.
    • Application Website/Homepage: The URL of your application.
    • Redirect URIs (for OAuth 2.0): For OAuth 2.0 flows like the Authorization Code Grant, you must specify one or more redirect URIs. These are the URLs to which Freelancer will redirect the user's browser after they authorize your application. These URIs must be exact and pre-registered for security purposes.
    • Application Description: A brief explanation of what your application does.
  4. Obtain Client ID and Client Secret: Upon successful registration, Freelancer will issue you a Client ID and a Client Secret. The Client ID is a public identifier for your application, while the Client Secret is a confidential key that should be kept secure. The Client Secret is used by your application to authenticate itself to Freelancer's authorization server when requesting access tokens. Treat your Client Secret like a password and never embed it directly in client-side code or public repositories.
  5. Review API Permissions/Scopes: During or after registration, you may need to define the specific permissions (scopes) your application requires. Scopes dictate what resources your application can access and what actions it can perform on behalf of a user. Requesting only the necessary scopes adheres to the principle of least privilege, enhancing security.

Always refer to the official Freelancer API documentation for the most current and detailed instructions on credential setup, as specifics can evolve.

Authenticated request example

Once you have obtained your Client ID and Client Secret, and a user has authorized your application (for OAuth 2.0 Authorization Code Grant), you can exchange the authorization code for an access token. This access token is then used to make authenticated API requests.

Here's a conceptual example using the OAuth 2.0 Authorization Code Grant flow, assuming you've already received an authorization_code from the user's browser redirect:

POST /oauth/token HTTP/1.1
Host: www.freelancer.com
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&code=YOUR_AUTHORIZATION_CODE&redirect_uri=YOUR_REGISTERED_REDIRECT_URI&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET

A successful response will typically return a JSON object containing the access_token, its token_type (usually Bearer), its expires_in duration, and optionally a refresh_token:

{
  "access_token": "YOUR_ACCESS_TOKEN",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "YOUR_REFRESH_TOKEN",
  "scope": "read write"
}

With the access_token, you can now make authenticated API requests to protected resources. The token is included in the Authorization header using the Bearer scheme:

GET /api/users/v1/self HTTP/1.1
Host: www.freelancer.com
Authorization: Bearer YOUR_ACCESS_TOKEN

This example demonstrates how the access token acts as a credential for subsequent API calls, granting your application temporary, authorized access to user data or platform functions without exposing the user's primary login credentials.

Security best practices

Maintaining strong security practices is paramount when integrating with the Freelancer platform and managing user data. Adhering to these guidelines helps protect both your application and your users:

  • Protect Your Client Secret: The Client Secret issued for your application is a critical credential. Never hardcode it into client-side code, embed it in public repositories, or transmit it insecurely. For server-side applications, store it in environment variables or a secure key management system.
  • Use HTTPS/TLS for All Communications: Ensure all interactions with Freelancer's API, including token exchange and subsequent API calls, occur over HTTPS. This encrypts data in transit, protecting against eavesdropping and tampering. Freelancer mandates TLS for its API endpoints.
  • Implement Secure Redirect URIs: For OAuth 2.0 flows, register specific, secure redirect_uris. Avoid using wildcard URIs. Ensure your server validates the redirect_uri parameter to prevent open redirect vulnerabilities.
  • Validate State Parameters: When using OAuth 2.0 Authorization Code or Implicit flows, generate and validate a unique, unguessable state parameter for each authorization request. This protects against Cross-Site Request Forgery (CSRF) attacks.
  • Refresh Tokens Securely: If your application uses refresh tokens, store them securely (e.g., in an encrypted database for server-side applications). Refresh tokens should have a longer lifespan than access tokens and be used to obtain new access tokens without requiring the user to re-authenticate. Implement refresh token rotation if supported.
  • Handle Access Tokens Carefully: Access tokens have a limited lifespan. Your application should be designed to handle token expiration gracefully by requesting a new access token using a refresh token (if available) or by prompting the user to re-authenticate. Avoid storing access tokens in persistent client-side storage where they could be easily compromised.
  • Implement Least Privilege: Request only the minimum necessary API scopes (permissions) for your application to function. This limits the potential impact if your application's credentials are compromised.
  • Regularly Review Logs: Monitor your application's authentication and API access logs for unusual activity or potential security incidents.
  • Stay Updated: Keep your application's dependencies and frameworks updated to patch known vulnerabilities. Regularly check Freelancer's API documentation for updates to authentication methods or security recommendations.
  • Educate Users on 2FA: Encourage your users to enable two-factor authentication on their Freelancer accounts to add an extra layer of security beyond just a password. This is a critical step for protecting individual accounts on the platform.
  • Adhere to Freelancer's Terms of Service: Always operate within the guidelines set forth by Freelancer to ensure compliance and avoid account suspensions or legal issues.