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.
This commit is contained in:
2019-06-19 10:39:34 -03:00
parent 546814b26c
commit d772ee5d47
5 changed files with 169 additions and 2 deletions

34
src/auth.php Normal file
View File

@@ -0,0 +1,34 @@
<?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';
}
}