question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with global auth token in IntelliJ context

See original GitHub issue

Hi,

The IntelliJ HTTP Client plugin keeps client.global env parameters between runs. httpyac doesn’t it seems?

We have a setup in our structure where we have a login job setup:

### User Login
POST {{auth0_base_url}}/oauth/token
Content-Type: application/json

{
 "client_id": "{{user_auth_client_id}}",
 "client_secret": "{{user_auth_client_secret}}",
 "grant_type": "http://someauth.com/realm",
 "username": "{{user_auth_username}}",
 "password": "{{user_auth_password}}",
 "audience": "an/audience",
 "realm": "Username-Password-Authentication",
 "scope": "openid"
}
> ./login.js

with a script like this:

client.test('Token retrieved successfully', function () {
  client.assert(response.status === 200, 'Response status is not 200')
  var access = response.body.access_token
  if (access) {
    client.global.set('user_access_token', access)
  }
})

This user_access_token is stored globally in the IntelliJ plugin in a way where this env parameter is available to requests that are executed later.

So, If I run:

### List companies
GET {{my_base_url}}/api/companies
Authorization: Bearer {{user_access_token}}

it will work just fine. But If I do this in httpyac, I get the error:

...ReferenceError: user_access_token is not defined at Object.userJS...

So, my questions are:

  • Is this intended behaviour?
  • Do you have a suggestions on how I could solve this scenario for httpyac, without breaking this logic within IntelliJ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AnWebercommented, Apr 26, 2021

the --interactive fix is not needed in VS Code plugin. The intellij variables are cached as long as my extension is active and therefore it should just work there now. Prerequisite is the version 2.5.0

0reactions
lazeecommented, Apr 26, 2021

AND: Thank you for sharing this tool with us! It is so cool and a great timesaver… 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolved: Problem with GitHub token authentication
Using PhpStorm 2017.3.4, I'm trying to follow the instructions at https://intellij-support.jetbrains.com/hc/en-us/articles/206537004 ...
Read more >
Support token capturing for an authentication by JWT - YouTrack
Now it's possible to execute authorization request, copy token from a response and paste it into a variable or next request. It's tedious...
Read more >
HTTP Client file not reading environment variables
Deleting and recreating the http-client.private.env.json file and restarting the IDE; Using a http-client.env.json file instead (and restarting ...
Read more >
Manage tasks and contexts | IntelliJ IDEA Documentation
Integrate your issue tracker in IntelliJ IDEA. Open, update, and close tickets, track the time you spend on a task right from the...
Read more >
Exploring the HTTP request syntax | IntelliJ IDEA Documentation
In the Java context, you can use code completion Ctrl+Space to specify ... Basic authentication GET http://example.com Authorization: Basic ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found