Authentication
Overview of authentication API methods
Credentials authentication
POST
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.
Path Parameters
Request Body
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
await membershipService.AuthenticateCredentialsAsync(
"test@email.com",
"password123"
);
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',
]);
}
}
Microsoft authentication
POST
https://api.codemash.io/{version}/auth/aad
Authenticate a user using Microsoft. Also supports GET method with body parameters in a query string.
Path Parameters
Request Body
Logout
POST
https://api.codemash.io/auth/logout
Logout a user using any of the authentication providers.
Path Parameters
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
await membershipService.LogoutAsync("{BEARER_TOKEN}");
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},
]);
}
}
Check authentication
POST
https://api.codemash.io/:version/auth
Check if the user is authenticated (if authorization token is valid). Also, supports GET method.
Path Parameters
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
await membershipService.AuthenticateCredentialsAsync(
"test@email.com",
"password123"
);
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();
}
}