@@ -697,16 +697,16 @@ 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 scope2 ;
705+ QStringList scopeAuthorizationFlow ;
706706 { {#scopes} }
707- scope2 .append("{ {scope} }");
707+ scopeAuthorizationFlow .append("{ {scope} }");
708708 { {/scopes} }
709- auto token2 = _authFlow.getToken(scope2 .join(" "));
709+ auto token2 = _authFlow.getToken(scopeAuthorizationFlow .join(" "));
710710 if(token2.isValid())
711711 input.headers.insert("Authorization", "Bearer " + token2.getToken());
712712
@@ -725,18 +725,18 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
725725 });
726726
727727 _latestInput = input;
728- _latestScope = scope2 ;{ {/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 scope1 ;
735+ QStringList scopeImplicitFlow ;
736736 { {#scopes} }
737- scope1 .append("{ {scope} }");
737+ scopeImplicitFlow .append("{ {scope} }");
738738 { {/scopes} }
739- auto token1 = _implicitFlow.getToken(scope1 .join(" "));
739+ auto token1 = _implicitFlow.getToken(scopeImplicitFlow .join(" "));
740740 if(token1.isValid())
741741 input.headers.insert("Authorization", "Bearer " + token1.getToken());
742742
@@ -755,18 +755,18 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
755755 });
756756
757757 _latestInput = input;
758- _latestScope = scope1 ;{ {/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 scope3 ;
765+ QStringList scopeClientCredentialsFlow ;
766766 { {#scopes} }
767- scope3 .append("{ {scope} }");
767+ scopeClientCredentialsFlow .append("{ {scope} }");
768768 { {/scopes} }
769- auto token3 = _credentialFlow.getToken(scope3 .join(" "));
769+ auto token3 = _credentialFlow.getToken(scopeClientCredentialsFlow .join(" "));
770770 if(token3.isValid())
771771 input.headers.insert("Authorization", "Bearer " + token3.getToken());
772772
@@ -785,18 +785,18 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
785785 });
786786
787787 _latestInput = input;
788- _latestScope = scope3 ;{ {/isApplication} }
788+ _latestScope = scopeClientCredentialsFlow ;{ {/isApplication} }
789789 { {#isPassword} }
790- _OauthMethod = 4 ;
790+ _OauthMethod = OauthMethod::ResourceOwnserPasswordFlow ;
791791 _passwordFlow.link();
792792 _authFlow.unlink();
793793 _implicitFlow.unlink();
794794 _credentialFlow.unlink();
795- QStringList scope4 ;
795+ QStringList scopeResourceOwnerPasswordFlow ;
796796 { {#scopes} }
797- scope4 .append("{ {scope} }");
797+ scopeResourceOwnerPasswordFlow .append("{ {scope} }");
798798 { {/scopes} }
799- auto token4 = _passwordFlow.getToken(scope4 .join(" "));
799+ auto token4 = _passwordFlow.getToken(scopeResourceOwnerPasswordFlow .join(" "));
800800 if(token4.isValid())
801801 input.headers.insert("Authorization", "Bearer " + token4.getToken());
802802
@@ -815,7 +815,7 @@ void {{classname}}::{{nickname}}({{#allParams}}{{#required}}const {{{dataType}}}
815815 });
816816
817817 _latestInput = input;
818- _latestScope = scope4 ;
818+ _latestScope = scopeResourceOwnerPasswordFlow ;
819819 { {/isPassword} }{ {/isOAuth} }{ {/authMethods} }
820820
821821 worker->execute(&input);
@@ -960,11 +960,11 @@ void {{classname}}::{{nickname}}Callback({{prefix}}HttpRequestWorker *worker) {
960960
961961{ {/operation} }
962962{ {/operations} }
963- void { {classname} }::tokenAvailable(){
963+ void { {classname} }::tokenAvailable() {
964964
965965 oauthToken token;
966966 switch (_OauthMethod) {
967- case 1: //implicit flow
967+ case OauthMethod::ImplicitFlow:
968968 token = _implicitFlow.getToken(_latestScope.join(" " ));
969969 if (token.isValid()){
970970 _latestInput.headers.insert (" Authorization" , " Bearer " + token.getToken());
@@ -974,7 +974,7 @@ void {{classname}}::tokenAvailable(){
974974 qDebug() << " Could not retrieve a valid token" ;
975975 }
976976 break;
977- case 2: //authorization flow
977+ case OauthMethod::AuthorizationFlow:
978978 token = _authFlow.getToken(_latestScope.join(" "));
979979 if(token.isValid()){
980980 _latestInput.headers.insert (" Authorization" , " Bearer " + token.getToken());
@@ -984,7 +984,7 @@ void {{classname}}::tokenAvailable(){
984984 qDebug() << " Could not retrieve a valid token" ;
985985 }
986986 break;
987- case 3: //client credentials flow
987+ case OauthMethod::ClientCredentialsFlow:
988988 token = _credentialFlow.getToken(_latestScope.join(" "));
989989 if(token.isValid()){
990990 _latestInput.headers.insert (" Authorization" , " Bearer " + token.getToken());
@@ -994,7 +994,7 @@ void {{classname}}::tokenAvailable(){
994994 qDebug() << " Could not retrieve a valid token" ;
995995 }
996996 break;
997- case 4: //resource owner password flow
997+ case OauthMethod::ResourceOwnerPasswordFlow:
998998 token = _passwordFlow.getToken(_latestScope.join(" "));
999999 if(token.isValid()){
10001000 _latestInput.headers.insert (" Authorization" , " Bearer " + token.getToken());
0 commit comments