mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 19:33:55 +00:00
[Dart] Allow setting an accessToken for OAuth (#7528)
* dart - allow setting an accessToken for oauth * Remove unneeded accessToken member
This commit is contained in:
parent
eb35870d11
commit
f1638a659a
@ -153,4 +153,12 @@ class ApiClient {
|
|||||||
auth.applyToParams(queryParams, headerParams);
|
auth.applyToParams(queryParams, headerParams);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setAccessToken(String accessToken) {
|
||||||
|
_authentications.forEach((key, auth) {
|
||||||
|
if (auth is OAuth) {
|
||||||
|
auth.setAccessToken(accessToken);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,19 @@
|
|||||||
part of {{pubName}}.api;
|
part of {{pubName}}.api;
|
||||||
|
|
||||||
class OAuth implements Authentication {
|
class OAuth implements Authentication {
|
||||||
|
String accessToken;
|
||||||
|
|
||||||
|
OAuth({this.accessToken}) {
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
|
||||||
// TODO: support oauth
|
if (accessToken != null) {
|
||||||
|
headerParams["Authorization"] = "Bearer " + accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAccessToken(String accessToken) {
|
||||||
|
this.accessToken = accessToken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user