Skip to content
Get started

Authenticate User

client.profile.authenticate(ProfileAuthenticateParams { emailaddress, password } body?, RequestOptionsoptions?): ProfileAuthenticateResponse { Data, Metadata }
POST/profile/authenticate

Perform user authentication, returning a model which includes the users profile and a JWT auth token to re-use in subsequent requests.

ParametersExpand Collapse
body: ProfileAuthenticateParams { emailaddress, password }
emailaddress?: string
password?: string
ReturnsExpand Collapse
ProfileAuthenticateResponse { Data, Metadata }
Data: Data { access_token, UserProfile }
access_token: string

JWT Bearer Token to use in subsequent authenticated requests

minLength1
UserProfile: UserProfile { DateCreated, ID, IsProfilePublic, 11 more }

Full user profile, including non-public fields such as Email Address

DateCreated: string
minLength1
ID: number
IsProfilePublic: boolean
Username: string
minLength1
DateLastLogin?: string
minLength1
EmailAddress?: string
minLength1
Latitude?: number
Location?: string
minLength1
Longitude?: number
Permissions?: string
minLength1
Profile?: string
minLength1
ProfileImageURL?: string
minLength1
ReputationPoints?: number
WebsiteURL?: string
minLength1
Metadata: Metadata { StatusCode }
StatusCode: number

Authenticate User

import Ocm from 'ocm-sdk';

const client = new Ocm({
  apiKey: process.env['OCM_API_KEY'], // This is the default and can be omitted
});

const response = await client.profile.authenticate({ emailaddress: 'string', password: 'string' });

console.log(response.Data);
{
  "Data": {
    "access_token": "x",
    "UserProfile": {
      "DateCreated": "x",
      "ID": 0,
      "IsProfilePublic": true,
      "Username": "x",
      "DateLastLogin": "x",
      "EmailAddress": "x",
      "Latitude": 0,
      "Location": "x",
      "Longitude": 0,
      "Permissions": "x",
      "Profile": "x",
      "ProfileImageURL": "x",
      "ReputationPoints": 0,
      "WebsiteURL": "x"
    }
  },
  "Metadata": {
    "StatusCode": 0
  }
}
Returns Examples
{
  "Data": {
    "access_token": "x",
    "UserProfile": {
      "DateCreated": "x",
      "ID": 0,
      "IsProfilePublic": true,
      "Username": "x",
      "DateLastLogin": "x",
      "EmailAddress": "x",
      "Latitude": 0,
      "Location": "x",
      "Longitude": 0,
      "Permissions": "x",
      "Profile": "x",
      "ProfileImageURL": "x",
      "ReputationPoints": 0,
      "WebsiteURL": "x"
    }
  },
  "Metadata": {
    "StatusCode": 0
  }
}