forked from loafle/openapi-generator-original
[Dart] Fix "basic" auth method and Add Bearer token support (#5743)
* added auth check and lint * fixed basic auth condition * Added bearer auth * updated samples * update dart petstore samples Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
parent
64c99504b4
commit
800293ccf9
@ -280,6 +280,7 @@ public class DartClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
final String authFolder = sourceFolder + File.separator + "lib" + File.separator + "auth";
|
final String authFolder = sourceFolder + File.separator + "lib" + File.separator + "auth";
|
||||||
supportingFiles.add(new SupportingFile("auth/authentication.mustache", authFolder, "authentication.dart"));
|
supportingFiles.add(new SupportingFile("auth/authentication.mustache", authFolder, "authentication.dart"));
|
||||||
supportingFiles.add(new SupportingFile("auth/http_basic_auth.mustache", authFolder, "http_basic_auth.dart"));
|
supportingFiles.add(new SupportingFile("auth/http_basic_auth.mustache", authFolder, "http_basic_auth.dart"));
|
||||||
|
supportingFiles.add(new SupportingFile("auth/http_bearer_auth.mustache", authFolder, "http_bearer_auth.dart"));
|
||||||
supportingFiles.add(new SupportingFile("auth/api_key_auth.mustache", authFolder, "api_key_auth.dart"));
|
supportingFiles.add(new SupportingFile("auth/api_key_auth.mustache", authFolder, "api_key_auth.dart"));
|
||||||
supportingFiles.add(new SupportingFile("auth/oauth.mustache", authFolder, "oauth.dart"));
|
supportingFiles.add(new SupportingFile("auth/oauth.mustache", authFolder, "oauth.dart"));
|
||||||
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
|
||||||
|
@ -53,9 +53,19 @@ import 'package:{{pubName}}/api.dart';
|
|||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
{{#authMethods}}
|
{{#authMethods}}
|
||||||
{{#isBasic}}
|
{{#isBasic}}
|
||||||
|
{{#isBasicBasic}}
|
||||||
// TODO Configure HTTP basic authorization: {{{name}}}
|
// TODO Configure HTTP basic authorization: {{{name}}}
|
||||||
//defaultApiClient.getAuthentication<HttpBasicAuth>('{{{name}}}').username = 'YOUR_USERNAME'
|
//defaultApiClient.getAuthentication<HttpBasicAuth>('{{{name}}}').username = 'YOUR_USERNAME'
|
||||||
//defaultApiClient.getAuthentication<HttpBasicAuth>('{{{name}}}').password = 'YOUR_PASSWORD';
|
//defaultApiClient.getAuthentication<HttpBasicAuth>('{{{name}}}').password = 'YOUR_PASSWORD';
|
||||||
|
{{/isBasicBasic}}
|
||||||
|
{{#isBasicBearer}}
|
||||||
|
// TODO Configure HTTP Bearer authorization: {{{name}}}
|
||||||
|
// Case 1. Use String Token
|
||||||
|
//defaultApiClient.getAuthentication<HttpBearerAuth>('{{{name}}}').setAccessToken('YOUR_ACCESS_TOKEN');
|
||||||
|
// Case 2. Use Function which generate token.
|
||||||
|
// String yourTokenGeneratorFunction() { ... }
|
||||||
|
//defaultApiClient.getAuthentication<HttpBearerAuth>('{{{name}}}').setAccessToken(yourTokenGeneratorFunction);
|
||||||
|
{{/isBasicBearer}}
|
||||||
{{/isBasic}}
|
{{/isBasic}}
|
||||||
{{#isApiKey}}
|
{{#isApiKey}}
|
||||||
// TODO Configure API key authorization: {{{name}}}
|
// TODO Configure API key authorization: {{{name}}}
|
||||||
@ -110,7 +120,13 @@ Class | Method | HTTP request | Description
|
|||||||
- **API key parameter name**: {{{keyParamName}}}
|
- **API key parameter name**: {{{keyParamName}}}
|
||||||
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
|
||||||
{{/isApiKey}}
|
{{/isApiKey}}
|
||||||
{{#isBasic}}- **Type**: HTTP basic authentication
|
{{#isBasic}}
|
||||||
|
{{#isBasicBasic}}
|
||||||
|
- **Type**: HTTP basicc authentication
|
||||||
|
{{/isBasicBasic}}
|
||||||
|
{{#isBasicBearer}}
|
||||||
|
- **Type**: HTTP Bearer authentication
|
||||||
|
{{/isBasicBearer}}
|
||||||
{{/isBasic}}
|
{{/isBasic}}
|
||||||
{{#isOAuth}}- **Type**: OAuth
|
{{#isOAuth}}- **Type**: OAuth
|
||||||
- **Flow**: {{{flow}}}
|
- **Flow**: {{{flow}}}
|
||||||
|
@ -19,10 +19,25 @@ class ApiClient {
|
|||||||
final _regMap = RegExp(r'^Map<String,(.*)>$');
|
final _regMap = RegExp(r'^Map<String,(.*)>$');
|
||||||
|
|
||||||
ApiClient({this.basePath = "{{{basePath}}}"}) {
|
ApiClient({this.basePath = "{{{basePath}}}"}) {
|
||||||
// Setup authentications (key: authentication name, value: authentication).{{#authMethods}}{{#isBasic}}
|
{{#hasAuthMethods}}
|
||||||
_authentications['{{name}}'] = HttpBasicAuth();{{/isBasic}}{{#isApiKey}}
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
_authentications['{{name}}'] = ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}");{{/isApiKey}}{{#isOAuth}}
|
{{#authMethods}}
|
||||||
_authentications['{{name}}'] = OAuth();{{/isOAuth}}{{/authMethods}}
|
{{#isBasic}}
|
||||||
|
{{#isBasicBasic}}
|
||||||
|
_authentications['{{name}}'] = HttpBasicAuth();
|
||||||
|
{{/isBasicBasic}}
|
||||||
|
{{#isBasicBearer}}
|
||||||
|
_authentications['{{name}}'] = HttpBearerAuth();
|
||||||
|
{{/isBasicBearer}}
|
||||||
|
{{/isBasic}}
|
||||||
|
{{#isApiKey}}
|
||||||
|
_authentications['{{name}}'] = ApiKeyAuth({{#isKeyInHeader}}"header"{{/isKeyInHeader}}{{^isKeyInHeader}}"query"{{/isKeyInHeader}}, "{{keyParamName}}");
|
||||||
|
{{/isApiKey}}
|
||||||
|
{{#isOAuth}}
|
||||||
|
_authentications['{{name}}'] = OAuth();
|
||||||
|
{{/isOAuth}}
|
||||||
|
{{/authMethods}}
|
||||||
|
{{/hasAuthMethods}}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addDefaultHeader(String key, String value) {
|
void addDefaultHeader(String key, String value) {
|
||||||
|
@ -28,9 +28,19 @@ import 'package:{{pubName}}/api.dart';
|
|||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
{{#authMethods}}
|
{{#authMethods}}
|
||||||
{{#isBasic}}
|
{{#isBasic}}
|
||||||
|
{{#isBasicBasic}}
|
||||||
// TODO Configure HTTP basic authorization: {{{name}}}
|
// TODO Configure HTTP basic authorization: {{{name}}}
|
||||||
//defaultApiClient.getAuthentication<HttpBasicAuth>('{{{name}}}').username = 'YOUR_USERNAME'
|
//defaultApiClient.getAuthentication<HttpBasicAuth>('{{{name}}}').username = 'YOUR_USERNAME'
|
||||||
//defaultApiClient.getAuthentication<HttpBasicAuth>('{{{name}}}').password = 'YOUR_PASSWORD';
|
//defaultApiClient.getAuthentication<HttpBasicAuth>('{{{name}}}').password = 'YOUR_PASSWORD';
|
||||||
|
{{/isBasicBasic}}
|
||||||
|
{{#isBasicBearer}}
|
||||||
|
// TODO Configure HTTP Bearer authorization: {{{name}}}
|
||||||
|
// Case 1. Use String Token
|
||||||
|
//defaultApiClient.getAuthentication<HttpBearerAuth>('{{{name}}}').setAccessToken('YOUR_ACCESS_TOKEN');
|
||||||
|
// Case 2. Use Function which generate token.
|
||||||
|
// String yourTokenGeneratorFunction() { ... }
|
||||||
|
//defaultApiClient.getAuthentication<HttpBearerAuth>('{{{name}}}').setAccessToken(yourTokenGeneratorFunction);
|
||||||
|
{{/isBasicBearer}}
|
||||||
{{/isBasic}}
|
{{/isBasic}}
|
||||||
{{#isApiKey}}
|
{{#isApiKey}}
|
||||||
// TODO Configure API key authorization: {{{name}}}
|
// TODO Configure API key authorization: {{{name}}}
|
||||||
|
@ -11,6 +11,7 @@ part 'auth/authentication.dart';
|
|||||||
part 'auth/api_key_auth.dart';
|
part 'auth/api_key_auth.dart';
|
||||||
part 'auth/oauth.dart';
|
part 'auth/oauth.dart';
|
||||||
part 'auth/http_basic_auth.dart';
|
part 'auth/http_basic_auth.dart';
|
||||||
|
part 'auth/http_bearer_auth.dart';
|
||||||
|
|
||||||
{{#apiInfo}}{{#apis}}part 'api/{{classFilename}}.dart';
|
{{#apiInfo}}{{#apis}}part 'api/{{classFilename}}.dart';
|
||||||
{{/apis}}{{/apiInfo}}
|
{{/apis}}{{/apiInfo}}
|
||||||
|
25
modules/openapi-generator/src/main/resources/dart2/auth/http_bearer_auth.mustache
vendored
Normal file
25
modules/openapi-generator/src/main/resources/dart2/auth/http_bearer_auth.mustache
vendored
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
part of {{pubName}}.api;
|
||||||
|
|
||||||
|
class HttpBearerAuth implements Authentication {
|
||||||
|
dynamic _accessToken;
|
||||||
|
|
||||||
|
HttpBearerAuth() { }
|
||||||
|
|
||||||
|
@override
|
||||||
|
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||||
|
if (_accessToken is String) {
|
||||||
|
headerParams["Authorization"] = "Bearer " + _accessToken;
|
||||||
|
} else if (_accessToken is String Function()){
|
||||||
|
headerParams["Authorization"] = "Bearer " + _accessToken();
|
||||||
|
} else {
|
||||||
|
throw ArgumentError('Type of Bearer accessToken should be String or String Function().');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAccessToken(dynamic accessToken) {
|
||||||
|
if (!((accessToken is String) | (accessToken is String Function()))){
|
||||||
|
throw ArgumentError('Type of Bearer accessToken should be String or String Function().');
|
||||||
|
}
|
||||||
|
this._accessToken = accessToken;
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
4.3.0-SNAPSHOT
|
4.3.1-SNAPSHOT
|
@ -0,0 +1,16 @@
|
|||||||
|
# openapi.model.InlineObject
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```dart
|
||||||
|
import 'package:openapi/api.dart';
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**name** | **String** | Updated name of the pet | [optional] [default to null]
|
||||||
|
**status** | **String** | Updated status of the pet | [optional] [default to null]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
|||||||
|
# openapi.model.InlineObject1
|
||||||
|
|
||||||
|
## Load the model package
|
||||||
|
```dart
|
||||||
|
import 'package:openapi/api.dart';
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
Name | Type | Description | Notes
|
||||||
|
------------ | ------------- | ------------- | -------------
|
||||||
|
**additionalMetadata** | **String** | Additional data to pass to server | [optional] [default to null]
|
||||||
|
**file** | [**MultipartFile**](File.md) | file to upload | [optional] [default to null]
|
||||||
|
|
||||||
|
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||||
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
|||||||
|
part of openapi.api;
|
||||||
|
|
||||||
|
class HttpBearerAuth implements Authentication {
|
||||||
|
dynamic _accessToken;
|
||||||
|
|
||||||
|
HttpBearerAuth() { }
|
||||||
|
|
||||||
|
@override
|
||||||
|
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||||
|
if (_accessToken is String) {
|
||||||
|
headerParams["Authorization"] = "Bearer " + _accessToken;
|
||||||
|
} else if (_accessToken is String Function()){
|
||||||
|
headerParams["Authorization"] = "Bearer " + _accessToken();
|
||||||
|
} else {
|
||||||
|
throw ArgumentError('Type of Bearer accessToken should be String or String Function().');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAccessToken(dynamic accessToken) {
|
||||||
|
if (!((accessToken is String) | (accessToken is String Function()))){
|
||||||
|
throw ArgumentError('Type of Bearer accessToken should be String or String Function().');
|
||||||
|
}
|
||||||
|
this._accessToken = accessToken;
|
||||||
|
}
|
||||||
|
}
|
@ -2,9 +2,9 @@ part of openapi.api;
|
|||||||
|
|
||||||
class InlineObject {
|
class InlineObject {
|
||||||
/* Updated name of the pet */
|
/* Updated name of the pet */
|
||||||
String name = null;
|
String name = null;
|
||||||
/* Updated status of the pet */
|
/* Updated status of the pet */
|
||||||
String status = null;
|
String status = null;
|
||||||
InlineObject();
|
InlineObject();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -14,27 +14,33 @@ class InlineObject {
|
|||||||
|
|
||||||
InlineObject.fromJson(Map<String, dynamic> json) {
|
InlineObject.fromJson(Map<String, dynamic> json) {
|
||||||
if (json == null) return;
|
if (json == null) return;
|
||||||
name = json['name'];
|
if (json['name'] == null) {
|
||||||
status = json['status'];
|
name = null;
|
||||||
|
} else {
|
||||||
|
name = json['name'];
|
||||||
|
}
|
||||||
|
if (json['status'] == null) {
|
||||||
|
status = null;
|
||||||
|
} else {
|
||||||
|
status = json['status'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
Map <String, dynamic> json = {};
|
return {
|
||||||
if (name != null)
|
'name': name,
|
||||||
json['name'] = name;
|
'status': status
|
||||||
if (status != null)
|
};
|
||||||
json['status'] = status;
|
|
||||||
return json;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<InlineObject> listFromJson(List<dynamic> json) {
|
static List<InlineObject> listFromJson(List<dynamic> json) {
|
||||||
return json == null ? List<InlineObject>() : json.map((value) => InlineObject.fromJson(value)).toList();
|
return json == null ? new List<InlineObject>() : json.map((value) => new InlineObject.fromJson(value)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Map<String, InlineObject> mapFromJson(Map<String, dynamic> json) {
|
static Map<String, InlineObject> mapFromJson(Map<String, Map<String, dynamic>> json) {
|
||||||
var map = Map<String, InlineObject>();
|
var map = new Map<String, InlineObject>();
|
||||||
if (json != null && json.isNotEmpty) {
|
if (json != null && json.length > 0) {
|
||||||
json.forEach((String key, dynamic value) => map[key] = InlineObject.fromJson(value));
|
json.forEach((String key, Map<String, dynamic> value) => map[key] = new InlineObject.fromJson(value));
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@ part of openapi.api;
|
|||||||
|
|
||||||
class InlineObject1 {
|
class InlineObject1 {
|
||||||
/* Additional data to pass to server */
|
/* Additional data to pass to server */
|
||||||
String additionalMetadata = null;
|
String additionalMetadata = null;
|
||||||
/* file to upload */
|
/* file to upload */
|
||||||
MultipartFile file = null;
|
MultipartFile file = null;
|
||||||
InlineObject1();
|
InlineObject1();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -14,29 +14,33 @@ class InlineObject1 {
|
|||||||
|
|
||||||
InlineObject1.fromJson(Map<String, dynamic> json) {
|
InlineObject1.fromJson(Map<String, dynamic> json) {
|
||||||
if (json == null) return;
|
if (json == null) return;
|
||||||
additionalMetadata = json['additionalMetadata'];
|
if (json['additionalMetadata'] == null) {
|
||||||
file = (json['file'] == null) ?
|
additionalMetadata = null;
|
||||||
null :
|
} else {
|
||||||
File.fromJson(json['file']);
|
additionalMetadata = json['additionalMetadata'];
|
||||||
|
}
|
||||||
|
if (json['file'] == null) {
|
||||||
|
file = null;
|
||||||
|
} else {
|
||||||
|
file = new File.fromJson(json['file']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
Map <String, dynamic> json = {};
|
return {
|
||||||
if (additionalMetadata != null)
|
'additionalMetadata': additionalMetadata,
|
||||||
json['additionalMetadata'] = additionalMetadata;
|
'file': file
|
||||||
if (file != null)
|
};
|
||||||
json['file'] = file;
|
|
||||||
return json;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<InlineObject1> listFromJson(List<dynamic> json) {
|
static List<InlineObject1> listFromJson(List<dynamic> json) {
|
||||||
return json == null ? List<InlineObject1>() : json.map((value) => InlineObject1.fromJson(value)).toList();
|
return json == null ? new List<InlineObject1>() : json.map((value) => new InlineObject1.fromJson(value)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Map<String, InlineObject1> mapFromJson(Map<String, dynamic> json) {
|
static Map<String, InlineObject1> mapFromJson(Map<String, Map<String, dynamic>> json) {
|
||||||
var map = Map<String, InlineObject1>();
|
var map = new Map<String, InlineObject1>();
|
||||||
if (json != null && json.isNotEmpty) {
|
if (json != null && json.length > 0) {
|
||||||
json.forEach((String key, dynamic value) => map[key] = InlineObject1.fromJson(value));
|
json.forEach((String key, Map<String, dynamic> value) => map[key] = new InlineObject1.fromJson(value));
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
part of openapi.api;
|
||||||
|
|
||||||
|
class HttpBearerAuth implements Authentication {
|
||||||
|
dynamic _accessToken;
|
||||||
|
|
||||||
|
HttpBearerAuth() { }
|
||||||
|
|
||||||
|
@override
|
||||||
|
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||||
|
if (_accessToken is String) {
|
||||||
|
headerParams["Authorization"] = "Bearer " + _accessToken;
|
||||||
|
} else if (_accessToken is String Function()){
|
||||||
|
headerParams["Authorization"] = "Bearer " + _accessToken();
|
||||||
|
} else {
|
||||||
|
throw ArgumentError('Type of Bearer accessToken should be String or String Function().');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAccessToken(dynamic accessToken) {
|
||||||
|
if (!((accessToken is String) | (accessToken is String Function()))){
|
||||||
|
throw ArgumentError('Type of Bearer accessToken should be String or String Function().');
|
||||||
|
}
|
||||||
|
this._accessToken = accessToken;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
part of openapi.api;
|
||||||
|
|
||||||
|
class HttpBearerAuth implements Authentication {
|
||||||
|
dynamic _accessToken;
|
||||||
|
|
||||||
|
HttpBearerAuth() { }
|
||||||
|
|
||||||
|
@override
|
||||||
|
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||||
|
if (_accessToken is String) {
|
||||||
|
headerParams["Authorization"] = "Bearer " + _accessToken;
|
||||||
|
} else if (_accessToken is String Function()){
|
||||||
|
headerParams["Authorization"] = "Bearer " + _accessToken();
|
||||||
|
} else {
|
||||||
|
throw ArgumentError('Type of Bearer accessToken should be String or String Function().');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAccessToken(dynamic accessToken) {
|
||||||
|
if (!((accessToken is String) | (accessToken is String Function()))){
|
||||||
|
throw ArgumentError('Type of Bearer accessToken should be String or String Function().');
|
||||||
|
}
|
||||||
|
this._accessToken = accessToken;
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,7 @@ part 'auth/authentication.dart';
|
|||||||
part 'auth/api_key_auth.dart';
|
part 'auth/api_key_auth.dart';
|
||||||
part 'auth/oauth.dart';
|
part 'auth/oauth.dart';
|
||||||
part 'auth/http_basic_auth.dart';
|
part 'auth/http_basic_auth.dart';
|
||||||
|
part 'auth/http_bearer_auth.dart';
|
||||||
|
|
||||||
part 'api/pet_api.dart';
|
part 'api/pet_api.dart';
|
||||||
part 'api/store_api.dart';
|
part 'api/store_api.dart';
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
part of openapi.api;
|
||||||
|
|
||||||
|
class HttpBearerAuth implements Authentication {
|
||||||
|
dynamic _accessToken;
|
||||||
|
|
||||||
|
HttpBearerAuth() { }
|
||||||
|
|
||||||
|
@override
|
||||||
|
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||||
|
if (_accessToken is String) {
|
||||||
|
headerParams["Authorization"] = "Bearer " + _accessToken;
|
||||||
|
} else if (_accessToken is String Function()){
|
||||||
|
headerParams["Authorization"] = "Bearer " + _accessToken();
|
||||||
|
} else {
|
||||||
|
throw ArgumentError('Type of Bearer accessToken should be String or String Function().');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAccessToken(dynamic accessToken) {
|
||||||
|
if (!((accessToken is String) | (accessToken is String Function()))){
|
||||||
|
throw ArgumentError('Type of Bearer accessToken should be String or String Function().');
|
||||||
|
}
|
||||||
|
this._accessToken = accessToken;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user