Question: Trying to read data of specific envelopes from DocuSign using completely backend java process ... and after some trial and error I've obtained AccessToken with JWT grant but still getting authorization error when asking for actual data :(

* Defined new integration key 9xxx7e
	+ User Application: Authorization Code Grant
	+ No secrets added
	+ Service Integration - uploaded public RSA key
	+ Added one Redirect URI (regardless I don't need any)
* Manual confirmation of corresponding link : <https://account-d.docusign.com/oauth/auth?response_type=code&scope=signature%20impersonation&client_id=9xxx7e&state=123&redirect_uri=https://my.redirect.net/DocuSign> ... assuming it is just one-time action
* Successfully requested Access Token using java code (using com.docusign:docusign-esign-java:3.10.1)

```
ApiClient = new ApiClient(ApiClient.DEMO_REST_BASEPATH);
OAuthToken token = apiClient.requestJWTApplicationToken(integrationKeyJwt, scopes, privateKeyFileContent, 3600);

```

* Trying to get envelope data using simple HttpGet

```
HttpGet request = new HttpGet("https://demo.docusign.net/restapi/v2.1/accounts/6xxx1e/envelopes");
request.addHeader("Content-Type", "application/json");
request.addHeader("Authorization", "Bearer " + token.getAccessToken());

```

* but still got 401 response with content:

`{"errorCode":"AUTHORIZATION_INVALID_TOKEN","message":"The access token provided is expired, revoked or malformed. Authentication for System Application failed."}`

Please any idea what is wrong? How to obtain correct Access Token?

P.S.: I also tried to get Authorization Code Grant without JWT or implicit grant but no luck without browser tough :(

Answer: 
there are 2 major problems that are there.

1. You are trying to access a static variable outside a class which is wrong. This problem can be fixed by adding `List<int> listOutside = Lists().list[0];` (notice the parentheses)
2. By accessing the `list[0];` you are saying that the element always exists but here the compiler comes into play saying that this is a nullable list (`List<int>?`) which you are trying to assign to `List<int>` which is not possible as both have different types. This problem can be quickly fixed by using `!` at the end `Lists().list[0]!;`

But note that this comes with a side effect that if there is no element at `0`the index then this will throw NPE.

**NOTE:** Always avoid using `!` in expressions where you are not sure that it is not nullable.
`?` means that this field can have the null value. The Dart language now supports sound null safety and to indicate that a variable might have the value `null`, just add `?` to its type declaration:

```dart
int? aNullableInt = null;

```

For your problem, you try to access list variable as a static usage and you use late but you initialize field immediately. For this reason, you can omit late and put static.

This usage could solve your problem:

```dart
static var list = Map<int, List<int>>();

List<int> listOutside = Lists.list[0];

```