Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request com access token #129

Open
julioffigueiredo opened this issue Aug 21, 2019 · 1 comment
Open

Request com access token #129

julioffigueiredo opened this issue Aug 21, 2019 · 1 comment

Comments

@julioffigueiredo
Copy link

Não encontrei algum lugar como um fórum. Então vai a minha duvida aqui.
Preciso fazer um request de access token e depois passar nas requisições.
Como fazer o uso no seu componente? Hj faço tudo via componentes nativos na mão.

Nessa parte o pedido

Request.AddParameter('username',
                                     'username',
                                      TRESTRequestParameterKind.pkGETorPOST,
                                      []);
Request.AddParameter('password',
                                     'senha_user',
                                      TRESTRequestParameterKind.pkGETorPOST,
                                      []);
Request.AddParameter('grant_type',
                                     'password',
                                      TRESTRequestParameterKind.pkGETorPOST,
                                      []);

Aqui passar o token nas seguintes requisições:

Request.AddParameter('Authorization',
                                'Bearer ' + token,
                                TRESTRequestParameterKind.pkHTTPHEADER,
                                [poDoNotEncode]);
@pablogarayprosis
Copy link

pablogarayprosis commented Sep 28, 2023

Não sei se vai te ajudar, mas eu tenho feito dessa forma, adicionado o token no Header da requisição

res := RestClient1.Resource('https://sistema.com.br/api/metodpost').Header('Authorization', 'Bearer ' + token).Accept(RestUtils.MediaType_Json).ContentType(RestUtils.MediaType_Json).Post(json);
   if RestClient1.ResponseCode = 201 then
   begin
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants