@@ -697,18 +697,18 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
697697 Q_EMIT allPendingRequestsCompleted();
698698 }
699699 });{ {#authMethods} }{ {#isOAuth} }{ {#isCode} }
700- _OauthMethod = 2 ;
700+ _OauthMethod = OauthMethod::AuthorizationFlow ;
701701 _implicitFlow.unlink();
702702 _credentialFlow.unlink();
703703 _passwordFlow.unlink();
704704 _authFlow.link();
705- QStringList scope ;
705+ QStringList scopeAuthorizationFlow ;
706706 { {#scopes} }
707- scope .append("{ {scope} }");
707+ scopeAuthorizationFlow .append("{ {scope} }");
708708 { {/scopes} }
709- auto token = _authFlow.getToken(scope .join(" "));
710- if(token .isValid())
711- input.headers.insert("Authorization", "Bearer " + token .getToken());
709+ auto tokenAuthorizationFlow = _authFlow.getToken(scopeAuthorizationFlow .join(" "));
710+ if(tokenAuthorizationFlow .isValid())
711+ input.headers.insert("Authorization", "Bearer " + tokenAuthorizationFlow .getToken());
712712
713713 _latestWorker = new { {prefix} }HttpRequestWorker(this, _manager);
714714 _latestWorker->setTimeOut(_timeOut);
@@ -725,20 +725,20 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
725725 });
726726
727727 _latestInput = input;
728- _latestScope = scope ;{ {/isCode} }
728+ _latestScope = scopeAuthorizationFlow ;{ {/isCode} }
729729 { {#isImplicit} }
730- _OauthMethod = 1 ;
730+ _OauthMethod = OauthMethod::ImplicitFlow ;
731731 _implicitFlow.link();
732732 _passwordFlow.unlink();
733733 _authFlow.unlink();
734734 _credentialFlow.unlink();
735- QStringList scope ;
735+ QStringList scopeImplicitFlow ;
736736 { {#scopes} }
737- scope .append("{ {scope} }");
737+ scopeImplicitFlow .append("{ {scope} }");
738738 { {/scopes} }
739- auto token = _implicitFlow.getToken(scope .join(" "));
740- if(token .isValid())
741- input.headers.insert("Authorization", "Bearer " + token .getToken());
739+ auto tokenImplicitFlow = _implicitFlow.getToken(scopeImplicitFlow .join(" "));
740+ if(tokenImplicitFlow .isValid())
741+ input.headers.insert("Authorization", "Bearer " + tokenImplicitFlow .getToken());
742742
743743 _latestWorker = new { {prefix} }HttpRequestWorker(this, _manager);
744744 _latestWorker->setTimeOut(_timeOut);
@@ -755,20 +755,20 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
755755 });
756756
757757 _latestInput = input;
758- _latestScope = scope ;{ {/isImplicit} }
758+ _latestScope = scopeImplicitFlow ;{ {/isImplicit} }
759759 { {#isApplication} }
760- _OauthMethod = 3 ;
760+ _OauthMethod = OauthMethod::ClientCredentialsFlow ;
761761 _authFlow.unlink();
762762 _implicitFlow.unlink();
763763 _passwordFlow.unlink();
764764 _credentialFlow.link();
765- QStringList scope ;
765+ QStringList scopeClientCredentialsFlow ;
766766 { {#scopes} }
767- scope .append("{ {scope} }");
767+ scopeClientCredentialsFlow .append("{ {scope} }");
768768 { {/scopes} }
769- auto token = _credentialFlow.getToken(scope .join(" "));
770- if(token .isValid())
771- input.headers.insert("Authorization", "Bearer " + token .getToken());
769+ auto tokenClientCredentialsFlow = _credentialFlow.getToken(scopeClientCredentialsFlow .join(" "));
770+ if(tokenClientCredentialsFlow .isValid())
771+ input.headers.insert("Authorization", "Bearer " + tokenClientCredentialsFlow .getToken());
772772
773773 _latestWorker = new { {prefix} }HttpRequestWorker(this, _manager);
774774 _latestWorker->setTimeOut(_timeOut);
@@ -785,20 +785,20 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
785785 });
786786
787787 _latestInput = input;
788- _latestScope = scope ;{ {/isApplication} }
788+ _latestScope = scopeClientCredentialsFlow ;{ {/isApplication} }
789789 { {#isPassword} }
790- _OauthMethod = 4 ;
790+ _OauthMethod = OauthMethod::ResourceOwnerPasswordFlow ;
791791 _passwordFlow.link();
792792 _authFlow.unlink();
793793 _implicitFlow.unlink();
794794 _credentialFlow.unlink();
795- QStringList scope ;
795+ QStringList scopeResourceOwnerPasswordFlow ;
796796 { {#scopes} }
797- scope .append("{ {scope} }");
797+ scopeResourceOwnerPasswordFlow .append("{ {scope} }");
798798 { {/scopes} }
799- auto token = _passwordFlow.getToken(scope .join(" "));
800- if(token .isValid())
801- input.headers.insert("Authorization", "Bearer " + token .getToken());
799+ auto tokenResourceOwnerPasswordFlow = _passwordFlow.getToken(scopeResourceOwnerPasswordFlow .join(" "));
800+ if(tokenResourceOwnerPasswordFlow .isValid())
801+ input.headers.insert("Authorization", "Bearer " + tokenResourceOwnerPasswordFlow .getToken());
802802
803803 _latestWorker = new { {prefix} }HttpRequestWorker(this, _manager);
804804 _latestWorker->setTimeOut(_timeOut);
@@ -815,7 +815,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
815815 });
816816
817817 _latestInput = input;
818- _latestScope = scope ;
818+ _latestScope = scopeResourceOwnerPasswordFlow ;
819819 { {/isPassword} }{ {/isOAuth} }{ {/authMethods} }
820820
821821 worker->execute(&input);
@@ -934,11 +934,11 @@ void {{classname}}::{{nickname}}Callback({{prefix}}HttpRequestWorker *worker) {
934934
935935{ {/operation} }
936936{ {/operations} }
937- void { {classname} }::tokenAvailable(){
937+ void { {classname} }::tokenAvailable() {
938938
939939 oauthToken token;
940940 switch (_OauthMethod) {
941- case 1: //implicit flow
941+ case OauthMethod::ImplicitFlow:
942942 token = _implicitFlow.getToken(_latestScope.join(" " ));
943943 if (token.isValid()){
944944 _latestInput.headers.insert (" Authorization" , " Bearer " + token.getToken());
@@ -948,7 +948,7 @@ void {{classname}}::tokenAvailable(){
948948 qDebug() << " Could not retrieve a valid token" ;
949949 }
950950 break;
951- case 2: //authorization flow
951+ case OauthMethod::AuthorizationFlow:
952952 token = _authFlow.getToken(_latestScope.join(" "));
953953 if(token.isValid()){
954954 _latestInput.headers.insert (" Authorization" , " Bearer " + token.getToken());
@@ -958,7 +958,7 @@ void {{classname}}::tokenAvailable(){
958958 qDebug() << " Could not retrieve a valid token" ;
959959 }
960960 break;
961- case 3: //client credentials flow
961+ case OauthMethod::ClientCredentialsFlow:
962962 token = _credentialFlow.getToken(_latestScope.join(" "));
963963 if(token.isValid()){
964964 _latestInput.headers.insert (" Authorization" , " Bearer " + token.getToken());
@@ -968,7 +968,7 @@ void {{classname}}::tokenAvailable(){
968968 qDebug() << " Could not retrieve a valid token" ;
969969 }
970970 break;
971- case 4: //resource owner password flow
971+ case OauthMethod::ResourceOwnerPasswordFlow:
972972 token = _passwordFlow.getToken(_latestScope.join(" "));
973973 if(token.isValid()){
974974 _latestInput.headers.insert (" Authorization" , " Bearer " + token.getToken());
0 commit comments