A Profile is an object that represents an authenticated user. The Profile object contains information relevant to a user in the form of normalized attributes.
After receiving the Profile for an authenticated user, use the Profile object attributes to persist relevant data to your application’s user model for the specific, authenticated user.
To surface additional attributes on the Profile, refer to the SSO custom attributes guide.
const profile = { id: 'prof_01DMC79VCBZ0NY2099737PSVF1', connectionId: 'conn_01E4ZCR3C56J083X43JQXF3JK5', organizationId: 'org_01EHWNCE74X7JSDV0X3SZ3KJNY', connectionType: 'OktaSAML', email: 'todd@example.com', firstName: 'Todd', idpId: '00u1a0ufowBJlzPlk357', lastName: 'Rundgren', role: { slug: 'admin' }, customAttributes: { department: 'Engineering', jobTitle: 'Software Engineer', }, object: 'profile', rawAttributes: {}, };
interface ProfileGet an access token along with the user Profile using the code passed to your Redirect URI.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const { access_token, profile, oauth_tokens } = await workos.sso.getProfileAndToken({ code: '01DMEK0J53CVMC32CK5SE0KZ8Q', clientId: 'client_123456789', });
sso .getProfileAndToken()Parameters objectReturns objectExchange an access token for a user’s Profile. Because this profile is returned in the Get a Profile and Token endpoint your application usually does not need to call this endpoint. It is available for any authentication flows that require an additional endpoint to retrieve a user’s profile.
import { WorkOS } from '@workos-inc/node'; const workos = new WorkOS('sk_example_123456789'); const profile = await workos.sso.getProfile({ accessToken: '01DMEK0J53CVMC32CK5SE0KZ8Q', });