Memsource-API/src/auth.php
Bruno Fontes d772ee5d47
Transforming into a composer package class
As I should use this into more than one project, it would be better to
turn it into a composer package. So I learn how to do that and use it at
work at the same time.
2019-06-19 10:39:34 -03:00

35 lines
894 B
PHP

<?php
/**
* A very compact and simple Memsource API library
*
* @author Bruno Fontes <developer@brunofontes.net>
* @link https://github.com/brunofontes
*/
namespace BrunoFontes\Memsource;
class Auth
{
protected $base_url;
private $_client_id;
private $_client_secret;
function __construct(string $base_url)
{
$this->base_url = $base_url;
}
/**
* Directly login and get a token valid for 24h
*
* @param string $username Memsource username
* @param string $password Memsource password
*
* @return string Authorization code valid for 24h only
*/
function login(string $username, string $password)
{
$authorize_url = $this->base_url . '/oauth/authorize';
return $authorize_url . '?response_type=code&client_id=' . $client_id . '&redirect_uri=' . $callback_uri . '&scope=openid';
}
}