@@ -170,7 +170,7 @@ void QgsO2::link()
170
170
setRefreshToken ( QString () );
171
171
setExpires ( 0 );
172
172
173
- if ( grantFlow_ == GrantFlowAuthorizationCode )
173
+ if ( grantFlow_ == GrantFlowAuthorizationCode || grantFlow_ == GrantFlowImplicit )
174
174
{
175
175
if ( mIsLocalHost )
176
176
{
@@ -238,6 +238,15 @@ void QgsO2::link()
238
238
}
239
239
}
240
240
241
+
242
+ void QgsO2::setState ( const QString & )
243
+ {
244
+ qsrand ( QTime::currentTime ().msec () );
245
+ state_ = QString::number ( qrand () );
246
+ Q_EMIT stateChanged ();
247
+ }
248
+
249
+
241
250
void QgsO2::onVerificationReceived ( QMap<QString, QString> response )
242
251
{
243
252
QgsDebugMsgLevel ( QStringLiteral ( " QgsO2::onVerificationReceived: Emitting closeBrowser()" ), 4 );
@@ -295,6 +304,32 @@ void QgsO2::onVerificationReceived( QMap<QString, QString> response )
295
304
connect ( tokenReply, &QNetworkReply::finished, this , &QgsO2::onTokenReplyFinished, Qt::QueuedConnection );
296
305
connect ( tokenReply, qgis::overload<QNetworkReply::NetworkError>::of ( &QNetworkReply::error ), this , &QgsO2::onTokenReplyError, Qt::QueuedConnection );
297
306
}
307
+ else if ( grantFlow_ == GrantFlowImplicit )
308
+ {
309
+ // Check for mandatory tokens
310
+ if ( response.contains ( O2_OAUTH2_ACCESS_TOKEN ) )
311
+ {
312
+ qDebug () << " O2::onVerificationReceived: Access token returned for implicit flow" ;
313
+ setToken ( response.value ( O2_OAUTH2_ACCESS_TOKEN ) );
314
+ if ( response.contains ( O2_OAUTH2_EXPIRES_IN ) )
315
+ {
316
+ bool ok = false ;
317
+ int expiresIn = response.value ( O2_OAUTH2_EXPIRES_IN ).toInt ( &ok );
318
+ if ( ok )
319
+ {
320
+ qDebug () << " O2::onVerificationReceived: Token expires in" << expiresIn << " seconds" ;
321
+ setExpires ( QDateTime::currentMSecsSinceEpoch () / 1000 + expiresIn );
322
+ }
323
+ }
324
+ setLinked ( true );
325
+ Q_EMIT linkingSucceeded ();
326
+ }
327
+ else
328
+ {
329
+ qWarning () << " O2::onVerificationReceived: Access token missing from response for implicit flow" ;
330
+ Q_EMIT linkingFailed ();
331
+ }
332
+ }
298
333
else
299
334
{
300
335
setToken ( response.value ( O2_OAUTH2_ACCESS_TOKEN ) );
0 commit comments