Grant Types Disponíveis
ConfigureConfigurar Authentication:autenticação: Obtainingobtendo Auma Session sessão
TheA API HelloCloud APIrequer requiresque thatum cliente tenha uma sessão ativa para consumir a client has an active session to consume the API. SessionsAs aresessões acquiredsão byadquiridas authenticatingpor withmeio thede autenticação no servidor OAuth 22, Server,usando usingum onedos oftipos thede availableconcessão grant types.disponíveis.
ConfigureConfigurar Granttipos Types de concessão
BeforeAntes youde canconsumir consume thea API, youvocê mustdeve firstprimeiro configureconfigurar o HelloCloud topara grantconceder access toacesso a client.um cliente. HelloCloud 7.10 providesoferece anum administrativepainel panel,administrativo, throughatravés whichdo youqual canvocê addpode clientsadicionar andclientes revokee revogar tokens. ToPara configureconfigurar theos granttipos types,de selectconcessão, theselecione admino panel,painel andde thenadministração selecte, OAuth2em Clientsseguida, andselecione Tokens:Clientes e Tokens OAuth2:
Available Grant Types Types Disponíveis
Versão HelloCloud |
|
---|---|
7.10.0 |
|
7.10. |
|
ClientConcessão Credentialsde Grant credenciais de cliente
AUma clientconcessão credentialsde grantcredenciais isde thecliente simplesté ofo allmais ofsimples thede grantstodos types,os thistipos grantde isconcessão; usedessa toconcessão authenticateé usada para autenticar uma máquina ou serviço. Selecione o novo cliente de credenciais do cliente:
Comece a machineconfigurar ora service. Select new client credentials client:concessão:
Begin configuring the grant:
|
|
|
|
|
|
|
|
TheO 'secret'segredo' willserá becriptografado hashedquando whensalvo saved,e andnão willestará notacessível beposteriormente. accessible later. TheO 'id' isé createdcriado bypelo HelloCloud ande willficará bevisível visibleassim onceque theo clientcliente isfor saved.salvo.
AuthenticationAutenticação withcom Clientcredenciais Credentials do cliente
POST /Api/access_token
RequiredParâmetros parameters obrigatórios
grant_type |
client_credentials |
client_id |
|
client_secret |
|
$ch = curl_init();
$header = array(array(
'Content-type: application/vnd.api+json',
'Accept: application/vnd.api+json',
);
$postStr = json_encode(array(array(
'grant_type' => 'client_credentials',
'client_id' => '3D7f3fda97-d8e2-b9ad-eb89-5a2fe9b07650',
'client_secret' => 'client_secret',
));
$url = 'https://path-to-instance/Api/access_token';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1)1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$output = curl_exec($ch);
{
"token_type":"Bearer",
"expires_in":3600,3600,
"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjdkOTEyODNhMjc1NDdkNDRlMzNmOTc5ZjVmMGRkYzQwNzg1ZGY5NGFhMWI5MDVlZGNmMzg3NWIxYjJkZDMzNDljZWEyNjZhMTQ2OTE5OWIzIn0.eyJhdWQiOiJzdWl0ZWNybV9jbGllbnQiLCJqdGkiOiI3ZDkxMjgzYTI3NTQ3ZDQ0ZTMzZjk3OWY1ZjBkZGM0MDc4NWRmOTRhYTFiOTA1ZWRjZjM4NzViMWIyZGQzMzQ5Y2VhMjY2YTE0NjkxOTliMyIsImlhdCI6MTUxODE5NTEwMiwibmJmIjoxNTE4MTk1MTAyLCJleHAiOjE1MTgxOTg3MDIsInN1YiI6IjEiLCJzY29wZXMiOltdfQ.EVGuRisoMxSIZut3IWtgOYISw8lEFSZgCWYCwseLEfOuPJ8lRMYL4OZxhu9gxJoGF0nj3yc6SYDPxovrsoj8bMoX38h4krMMOHFQLoizU0k2wAceOjZG1tWKPhID7KPT4TwoCXbb7MqAsYtVPExH4li7gSphJ8wvcWbFdS5em89Ndtwqq3faFtIq6bv1R4t0x98HHuT7sweHUJU40K9WQjbAfIOk8f5Y6T2wassN2wMCBB8CC6eUxLi14n2D6khHvkYvtPbXLHpXSHZWvEhqhvjAeSR5MmMrAth9WDSWUx7alO-ppsZpi8U7-g9Be5p6MRatc25voyTI2iTYbx02FQ",
}
token_type | |
---|---|
expires_in |
|
access_token |
|
Você pode armazenar o token ao portador em um banco de dados e usá-lo em suas solicitações assim:
You
$header can= storearray(
the'Content-type: bearerapplication/vnd.api+json',
token'Accept: inapplication/vnd.api+json',
a'Authorization: databaseBearer and' use. in$your_saved_access_token
your requests like this:);
$header = array(
'Content-type: application/vnd.api+json',
'Accept: application/vnd.api+json',
'Authorization: Bearer ' . $your_saved_access_token
);
PasswordConcessão Grant de senha
AUma passwordconcessão grantde issenha usedé forusada allowpara userspermitir toque logos intousuários façam login no HelloCloud withcom um nome de usuário e uma senha. Selecione a usernamenova andsenha do cliente:
Comece a password.configurar Selecta new password client:concessão:
Begin configuring grant:
|
|
|
|
|
|
TheO 'secret'segredo' willserá becriptografado hashedquando whensalvo saved,e andnão willestará notacessível beposteriormente. accessible later. TheO 'id' isé createdcriado bypelo HelloCloud ande willficará bevisível visibleassim onceque theo clientcliente isfor saved.salvo.
AuthenticationAutenticação withcom Passwordconcessão Grant de senha
POST /Api/access_token
POST /Api/access_token
RequiredParâmetros parameters obrigatórios
grant_type |
password |
client_id |
|
client_secret |
|
username |
admin |
password |
|
PleaseAltere changeos thevalores valuesem innegrito boldpara tocorresponder matchaos yourdetalhes chosende authenticationautenticação details.escolhidos.
$ch = curl_init();
$header = array(array(
'Content-type: application/vnd.api+json',
'Accept: application/vnd.api+json',
);
$postStr = json_encode(array(array(
'grant_type' => 'password',
'client_id' => '3D7f3fda97-d8e2-b9ad-eb89-5a2fe9b07650',
'client_secret' => 'client_secret',
'username' => 'admin',
'password' => 'admin',
));
$url = 'https://path-to-instance/Api/access_token';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $postStr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1)1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$output = curl_exec($ch);
{
"token_type":"Bearer",
"expires_in":3600,3600,
"access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjdkOTEyODNhMjc1NDdkNDRlMzNmOTc5ZjVmMGRkYzQwNzg1ZGY5NGFhMWI5MDVlZGNmMzg3NWIxYjJkZDMzNDljZWEyNjZhMTQ2OTE5OWIzIn0.eyJhdWQiOiJzdWl0ZWNybV9jbGllbnQiLCJqdGkiOiI3ZDkxMjgzYTI3NTQ3ZDQ0ZTMzZjk3OWY1ZjBkZGM0MDc4NWRmOTRhYTFiOTA1ZWRjZjM4NzViMWIyZGQzMzQ5Y2VhMjY2YTE0NjkxOTliMyIsImlhdCI6MTUxODE5NTEwMiwibmJmIjoxNTE4MTk1MTAyLCJleHAiOjE1MTgxOTg3MDIsInN1YiI6IjEiLCJzY29wZXMiOltdfQ.EVGuRisoMxSIZut3IWtgOYISw8lEFSZgCWYCwseLEfOuPJ8lRMYL4OZxhu9gxJoGF0nj3yc6SYDPxovrsoj8bMoX38h4krMMOHFQLoizU0k2wAceOjZG1tWKPhID7KPT4TwoCXbb7MqAsYtVPExH4li7gSphJ8wvcWbFdS5em89Ndtwqq3faFtIq6bv1R4t0x98HHuT7sweHUJU40K9WQjbAfIOk8f5Y6T2wassN2wMCBB8CC6eUxLi14n2D6khHvkYvtPbXLHpXSHZWvEhqhvjAeSR5MmMrAth9WDSWUx7alO-ppsZpi8U7-g9Be5p6MRatc25voyTI2iTYbx02FQ",
"refresh_token":"def50200d2fb757e4c01c333e96c827712dfd8f3e2c797db3e4e42734c8b4e7cba88a2dd8a9ce607358d634a51cadd7fa980d5acd692ab2c7a7da1d7a7f8246b22faf151dc11a758f9d8ea0b9aa3553f3cfd3751a927399ab964f219d086d36151d0f39c93aef4a846287e8467acea3dfde0bd2ac055ea7825dfb75aa5b8a084752de6d3976438631c3e539156a26bc10d0b7f057c092fce354bb10ff7ac2ab5fe6fd7af3ec7fa2599ec0f1e581837a6ca2441a80c01d997dac298e1f74573ac900dd4547d7a2a2807e9fb25438486c38f25be55d19cb8d72634d77c0a8dfaec80901c01745579d0f3822c717df21403440473c86277dc5590ce18acdb1222c1b95b516f3554c8b59255446bc15b457fdc17d5dcc0f06f7b2252581c810ca72b51618f820dbb2f414ea147add2658f8fbd5df20820843f98c22252dcffe127e6adb4a4cbe89ab0340f7ebe8d8177ef382569e2aa4a54d434adb797c5337bfdfffe27bd8d5cf4714054d4aef2372472ebb4"
}
token_type | |
---|---|
expires_in |
|
access_token |
|
refresh_token |
|
Você pode armazenar o token ao portador em um banco de dados e usá-lo em suas solicitações assim:
You can store the bearer token in a database and use in your requests like this:
$header = array(array(
'Content-type: application/vnd.api+json',
'Accept: application/vnd.api+json',
'Authorization: Bearer Bearer ' . $your_saved_access_token
);