Links

Authentication

Overview of authentication API methods
post
https://api.codemash.io
/:version/auth/credentials
Credentials authentication
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
await membershipService.AuthenticateCredentialsAsync(
"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' => '[email protected]',
'password' => 'password123',
]);
}
}
post
https://api.codemash.io
/{version}/auth/aad
Microsoft authentication
post
https://api.codemash.io
/auth/logout
Logout
.NET
Node
PHP
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},
]);
}
}
post
https://api.codemash.io
/:version/auth
Check authentication
.NET
Node
PHP
var client = new CodeMashClient(apiKey, projectId);
var membershipService = new CodeMashMembershipService(client);
await membershipService.AuthenticateCredentialsAsync(
"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();
}
}