Skip to main content

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:

 

Configure SuiteCRM APICaptura de Tela 2024-04-19 às 10.56.22.png

Available Grant Types Types Disponíveis

Versão HelloCloud Version Available Grant Types Disponíveis

7.10.0

PasswordConcessão Grantde senha

7.10.22+

PasswordConcessão Grant,de Clientsenha, credentialsconcessão Grantde credenciais do cliente


Create a new grantoauth_menu.png

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:

new_client_oauth.png

Comece a machineconfigurar ora service. Select new client credentials client:concessão:

Create a new client credentials grantclient_oauth.png

Begin configuring the grant:

Create a new Client


FieldCampo DescriptionDescrição

NameNome

ThisIsso makesfacilita ita easyidentificação todo identify the client.cliente.

SecretAlterar segredo

DefinesDefine the o  client_secret which  isque postedé topostado theno serverservidor duringdurante authentication.a autenticação.

IsÉ Confidentialconfidencial

AUm confidentialcliente clientconfidencial isé anum applicationaplicativo thatcapaz isde capable of keepingmanter a clientsenha passwordde confidentialum tocliente theconfidencial world.para o mundo.

AssociatedUsuário Userassociado

LimitsLimita theo clientacesso accessdo tocliente ao CRM, byassociando associatingo thecliente clientaos withprivilégios thede security privileges of segurança user.de um usuário.


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.

View a Client Credentials Clientclient_oauth_detail.png

AuthenticationAutenticação withcom Clientcredenciais Credentials do cliente 

POST /Api/access_token

RequiredParâmetros parameters obrigatórios 

paramparâmetro valuevalor

grant_type

client_credentials

client_id

ExampleClientNameExemploNomeCliente

client_secret

ExampleSecretPasswordExemploSecretPassword

ExampleSolicitação Requestde exemplo (PHP):
$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);
ExampleExemplo Response:de resposta:
{
      "token_type":"Bearer",
     "expires_in":3600,3600,
     "access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjdkOTEyODNhMjc1NDdkNDRlMzNmOTc5ZjVmMGRkYzQwNzg1ZGY5NGFhMWI5MDVlZGNmMzg3NWIxYjJkZDMzNDljZWEyNjZhMTQ2OTE5OWIzIn0.eyJhdWQiOiJzdWl0ZWNybV9jbGllbnQiLCJqdGkiOiI3ZDkxMjgzYTI3NTQ3ZDQ0ZTMzZjk3OWY1ZjBkZGM0MDc4NWRmOTRhYTFiOTA1ZWRjZjM4NzViMWIyZGQzMzQ5Y2VhMjY2YTE0NjkxOTliMyIsImlhdCI6MTUxODE5NTEwMiwibmJmIjoxNTE4MTk1MTAyLCJleHAiOjE1MTgxOTg3MDIsInN1YiI6IjEiLCJzY29wZXMiOltdfQ.EVGuRisoMxSIZut3IWtgOYISw8lEFSZgCWYCwseLEfOuPJ8lRMYL4OZxhu9gxJoGF0nj3yc6SYDPxovrsoj8bMoX38h4krMMOHFQLoizU0k2wAceOjZG1tWKPhID7KPT4TwoCXbb7MqAsYtVPExH4li7gSphJ8wvcWbFdS5em89Ndtwqq3faFtIq6bv1R4t0x98HHuT7sweHUJU40K9WQjbAfIOk8f5Y6T2wassN2wMCBB8CC6eUxLi14n2D6khHvkYvtPbXLHpXSHZWvEhqhvjAeSR5MmMrAth9WDSWUx7alO-ppsZpi8U7-g9Be5p6MRatc25voyTI2iTYbx02FQ",
}
token_type theo valor Bearer token value

expires_in

anum integernúmero representinginteiro theque representa o TTL of the accessdo token de acesso

access_token

um  JWT signed  withassinado the authorization server’s private key. It is required that you include this in the HTTP headers, each time you makecom a requestchave toprivada thedo servidor de autorização. É necessário incluir isso nos cabeçalhos HTTP, cada vez que você fizer uma solicitação à API


Você pode armazenar o token ao portador em um banco de dados e usá-lo em suas solicitações assim:


Example

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:

);
Example
$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:

oauth_password.png

Comece a password.configurar Selecta new password client:concessão:

Create a Password Client

Begin configuring grant:

Create a new Clientoauth_password_edit.png


NameNome

ThisIsso makesfacilita ita easyidentificação todo identify the client.cliente.

SecretAlterar segredo

DefinesDefine the o  client_secret which  isque postedé topostado theno serverservidor duringdurante authentication.a autenticação.

IsÉ Confidentialconfidencial

AUm confidentialcliente clientconfidencial isé anum applicationaplicativo thatcapaz isde capable of keepingmanter a clientsenha passwordde confidentialum tocliente theconfidencial world.para o mundo.


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.

View a password grant client

AuthenticationAutenticação withcom Passwordconcessão Grant de senha 

POST /Api/access_token
POST /Api/access_token

RequiredParâmetros parameters obrigatórios 

paramparâmetro valuevalor

grant_type

password

client_id

ExampleClientNameExemploNomeCliente

client_secret

ExampleSecretPasswordExemploSecretPassword

username

admin

password

secretsegredo


PleaseAltere changeos thevalores valuesem innegrito boldpara tocorresponder matchaos yourdetalhes chosende authenticationautenticação details.escolhidos.


ExampleSolicitação Requestde exemplo (PHP):
$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);
ExampleExemplo Response:de resposta:
{
      "token_type":"Bearer",
     "expires_in":3600,3600,
     "access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjdkOTEyODNhMjc1NDdkNDRlMzNmOTc5ZjVmMGRkYzQwNzg1ZGY5NGFhMWI5MDVlZGNmMzg3NWIxYjJkZDMzNDljZWEyNjZhMTQ2OTE5OWIzIn0.eyJhdWQiOiJzdWl0ZWNybV9jbGllbnQiLCJqdGkiOiI3ZDkxMjgzYTI3NTQ3ZDQ0ZTMzZjk3OWY1ZjBkZGM0MDc4NWRmOTRhYTFiOTA1ZWRjZjM4NzViMWIyZGQzMzQ5Y2VhMjY2YTE0NjkxOTliMyIsImlhdCI6MTUxODE5NTEwMiwibmJmIjoxNTE4MTk1MTAyLCJleHAiOjE1MTgxOTg3MDIsInN1YiI6IjEiLCJzY29wZXMiOltdfQ.EVGuRisoMxSIZut3IWtgOYISw8lEFSZgCWYCwseLEfOuPJ8lRMYL4OZxhu9gxJoGF0nj3yc6SYDPxovrsoj8bMoX38h4krMMOHFQLoizU0k2wAceOjZG1tWKPhID7KPT4TwoCXbb7MqAsYtVPExH4li7gSphJ8wvcWbFdS5em89Ndtwqq3faFtIq6bv1R4t0x98HHuT7sweHUJU40K9WQjbAfIOk8f5Y6T2wassN2wMCBB8CC6eUxLi14n2D6khHvkYvtPbXLHpXSHZWvEhqhvjAeSR5MmMrAth9WDSWUx7alO-ppsZpi8U7-g9Be5p6MRatc25voyTI2iTYbx02FQ",
     "refresh_token":"def50200d2fb757e4c01c333e96c827712dfd8f3e2c797db3e4e42734c8b4e7cba88a2dd8a9ce607358d634a51cadd7fa980d5acd692ab2c7a7da1d7a7f8246b22faf151dc11a758f9d8ea0b9aa3553f3cfd3751a927399ab964f219d086d36151d0f39c93aef4a846287e8467acea3dfde0bd2ac055ea7825dfb75aa5b8a084752de6d3976438631c3e539156a26bc10d0b7f057c092fce354bb10ff7ac2ab5fe6fd7af3ec7fa2599ec0f1e581837a6ca2441a80c01d997dac298e1f74573ac900dd4547d7a2a2807e9fb25438486c38f25be55d19cb8d72634d77c0a8dfaec80901c01745579d0f3822c717df21403440473c86277dc5590ce18acdb1222c1b95b516f3554c8b59255446bc15b457fdc17d5dcc0f06f7b2252581c810ca72b51618f820dbb2f414ea147add2658f8fbd5df20820843f98c22252dcffe127e6adb4a4cbe89ab0340f7ebe8d8177ef382569e2aa4a54d434adb797c5337bfdfffe27bd8d5cf4714054d4aef2372472ebb4"
}
token_type theo valor Bearer token value

expires_in

anum integernúmero representinginteiro theque representa o TTL of the accessdo token de acesso

access_token

um  JWT signed  withassinado the authorization server’s private key. It is required that you include this in the HTTP headers, each time you makecom a requestchave toprivada thedo servidor de autorização. É necessário incluir isso nos cabeçalhos HTTP, cada vez que você fizer uma solicitação à API

refresh_token

anuma encryptedcarga payloadcriptografada thatque canpode beser usedusada topara refreshatualizar the accesso token whende itacesso expires.quando ele expirar.


Você pode armazenar o token ao portador em um banco de dados e usá-lo em suas solicitações assim:


Exemplo

You can store the bearer token in a database and use in your requests like this:

Example
$header = array(array(
      'Content-type:  application/vnd.api+json',
      'Accept:  application/vnd.api+json',
      'Authorization: Bearer  Bearer '  .  $your_saved_access_token
);