Authentication API

Overview of authentication API methods

post
Credentials authentication

https://api.codemash.io/:version/auth/credentials
Authenticate a user using an email password pair. Also supports GET method with body parameters in a query string.
Request
Response
Request
Path Parameters
version
required
string
A version of the API endpoint.
Headers
x-cm-projectid
required
string
Your project's ID. Can be passed as a query parameter.
Body Parameters
password
required
string
User's login password.
userName
required
string
User's login e-mail address.
Response
200: OK
.NET
Node
PHP
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
await membershipService.AuthenticateCredentialsAsync(
"test@email.com",
"password123"
);
Node
PHP
use Codemash\CodemashClient;
use Codemash\CodemashAuth;
class CodemashService
{
protected CodemashAuth $codemashAuth;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new CodemashClient($secretKey, $projectId);
$this->codemashAuth = new CodemashAuth($client);
}
public function login()
{
$responseData = $codemashAuth->authenticate([
'userName' => 'test@email.com',
'password' => 'password123',
]);
}
}

post
Microsoft authentication

https://api.codemash.io/{version}/auth/aad
Authenticate a user using Microsoft. Also supports GET method with body parameters in a query string.
Request
Response
Request
Path Parameters
version
required
string
A version of the API endpoint.
Headers
x-cm-projectid
required
string
Your project's ID. Can be passed as a query parameter.
Body Parameters
mode
optional
string
Mode to use for authentication. If not passed, will use the default.
Response
200: OK

post
Logout

https://api.codemash.io/auth/logout
Logout a user using any of the authentication providers.
Request
Response
Request
Path Parameters
optional
string
Response
200: OK
.NET
Node
PHP
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
await membershipService.LogoutAsync("{BEARER_TOKEN}");
Node
PHP
use Codemash\CodemashClient;
use Codemash\CodemashAuth;
class CodemashService
{
protected CodemashAuth $codemashAuth;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new CodemashClient($secretKey, $projectId);
$this->codemashAuth = new CodemashAuth($client);
}
public function logout()
{
$responseData = $this->codemashAuth->logout([
'bearerToken' => '{BEARER_TOKEN},
]);
}
}

post
Check authentication

https://api.codemash.io/:version/auth
Check if the user is authenticated (if authorization token is valid). Also, supports GET method.
Request
Response
Request
Path Parameters
version
required
string
A version of the API endpoint.
Headers
Authorization
required
string
Secret API key which belongs to your project or user. Not required if using cookies with a session ID.
x-cm-projectid
required
string
Your project's ID. Can be passed as a query parameter.
Response
200: OK
.NET
Node
PHP
.NET
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
await membershipService.AuthenticateCredentialsAsync(
"test@email.com",
"password123"
);
Node
PHP
use Codemash\CodemashClient;
use Codemash\CodemashAuth;
class CodemashService
{
protected CodemashAuth $codemashAuth;
public function __construct()
{
$secretKey = '{YOUR_SECRET_KEY}';
$projectId = '{YOUR_PROJECT_ID}';
$client = new CodemashClient($secretKey, $projectId);
$this->codemashAuth = new CodemashAuth($client);
}
public function isAuthenticated()
{
$responseData = $this->codemashAuth->checkAuth();
}
}