QOAuth2AuthorizationCodeFlow Class | Qt Network Authorization 5.9

Qt Documentation (Technology Preview) | Qt Network Authorization | C++ Classes | QOAuth2AuthorizationCodeFlow

Qt 5.9.9 Reference Documentation

# QOAuth2AuthorizationCodeFlow Class

The QOAuth2AuthorizationCodeFlow class provides an implementation of the Authorization Code Grant flow. More...

Header: | #include <QOAuth2AuthorizationCodeFlow>
qmake: | QT += networkauth
Since: | Qt 5.8
Inherits: | QAbstractOAuth2

- List of all members, including inherited members

## Properties

- accessTokenUrl : QUrl

- 6 properties inherited from QAbstractOAuth2
- 4 properties inherited from QAbstractOAuth

## Public Functions

| QOAuth2AuthorizationCodeFlow(QObject *parent = nullptr)
| QOAuth2AuthorizationCodeFlow(QNetworkAccessManager *manager, QObject *parent = nullptr)
| QOAuth2AuthorizationCodeFlow(const QString &clientIdentifier, QNetworkAccessManager *manager, QObject *parent = nullptr)
| QOAuth2AuthorizationCodeFlow(const QUrl &authenticateUrl, const QUrl &accessTokenUrl, QNetworkAccessManager *manager, QObject *parent = nullptr)
| QOAuth2AuthorizationCodeFlow(const QString &clientIdentifier, const QUrl &authenticateUrl, const QUrl &accessTokenUrl, QNetworkAccessManager *manager, QObject *parent = nullptr)
| ~QOAuth2AuthorizationCodeFlow()
QUrl | accessTokenUrl() const
void | setAccessTokenUrl(const QUrl &accessTokenUrl)

## Reimplemented Public Functions

virtual QString | responseType() const override

- 19 public functions inherited from QAbstractOAuth2
- 20 public functions inherited from QAbstractOAuth

## Public Slots

virtual void | grant() override
void | refreshAccessToken()

- 1 public slot inherited from QAbstractOAuth

## Signals

void | accessTokenUrlChanged(const QUrl &accessTokenUrl)

- 8 signals inherited from QAbstractOAuth2
- 11 signals inherited from QAbstractOAuth

## Protected Functions

QUrl | buildAuthenticateUrl(const QVariantMap &parameters = QVariantMap())
void | requestAccessToken(const QString &code)

## Reimplemented Protected Functions

virtual void | resourceOwnerAuthorization(const QUrl &url, const QVariantMap &parameters = QVariantMap()) override

- 3 protected functions inherited from QAbstractOAuth

### Additional Inherited Members

- 1 static protected member inherited from QAbstractOAuth

## Detailed Description

The QOAuth2AuthorizationCodeFlow class provides an implementation of the Authorization Code Grant flow.

This class implements the Authorization Code Grant flow, which is used both to obtain and to refresh access tokens. It is a redirection-based flow so the user will need access to a web browser.

## Property Documentation

### accessTokenUrl : QUrl

This property holds the URL used to convert the temporary code received during the authorization response.

See also: Access Token Request

Access functions:

QUrl | accessTokenUrl() const
void | setAccessTokenUrl(const QUrl &accessTokenUrl)

Notifier signal:

void | accessTokenUrlChanged(const QUrl &accessTokenUrl)

## Member Function Documentation

### QOAuth2AuthorizationCodeFlow::QOAuth2AuthorizationCodeFlow(QObject *parent = nullptr)

Constructs a QOAuth2AuthorizationCodeFlow object with parent object parent.

### QOAuth2AuthorizationCodeFlow::QOAuth2AuthorizationCodeFlow(QNetworkAccessManager *manager, QObject *parent = nullptr)

Constructs a QOAuth2AuthorizationCodeFlow object using parent as parent and sets manager as the network access manager.

### QOAuth2AuthorizationCodeFlow::QOAuth2AuthorizationCodeFlow(const QString &clientIdentifier, QNetworkAccessManager *manager, QObject *parent = nullptr)

Constructs a QOAuth2AuthorizationCodeFlow object using parent as parent and sets manager as the network access manager. The client identifier is set to clientIdentifier.

### QOAuth2AuthorizationCodeFlow::QOAuth2AuthorizationCodeFlow(const QUrl &authenticateUrl, const QUrl &accessTokenUrl, QNetworkAccessManager *manager, QObject *parent = nullptr)

Constructs a QOAuth2AuthorizationCodeFlow object using parent as parent and sets manager as the network access manager. The authenticate URL is set to authenticateUrl and the access token URL is set to accessTokenUrl.

### QOAuth2AuthorizationCodeFlow::QOAuth2AuthorizationCodeFlow(const QString &clientIdentifier, const QUrl &authenticateUrl, const QUrl &accessTokenUrl, QNetworkAccessManager *manager, QObject *parent = nullptr)

Constructs a QOAuth2AuthorizationCodeFlow object using parent as parent and sets manager as the network access manager. The client identifier is set to clientIdentifier the authenticate URL is set to authenticateUrl and the access token URL is set to accessTokenUrl.

### QOAuth2AuthorizationCodeFlow::~QOAuth2AuthorizationCodeFlow()

Destroys the QOAuth2AuthorizationCodeFlow instance.

### QUrl QOAuth2AuthorizationCodeFlow::accessTokenUrl() const

Returns the URL used to request the access token.

Note: Getter function for property accessTokenUrl.

See also setAccessTokenUrl().

### `[protected]` QUrl QOAuth2AuthorizationCodeFlow::buildAuthenticateUrl(const QVariantMap &parameters = QVariantMap())

Generates an authentication URL to be used in the Authorization Request using parameters.

### `[override virtual slot]` void QOAuth2AuthorizationCodeFlow::grant()

Reimplemented from QAbstractOAuth::grant().

Starts the authentication flow as described in The OAuth 2.0 Authorization Framework

### `[slot]` void QOAuth2AuthorizationCodeFlow::refreshAccessToken()

Call this function to refresh the token. Access tokens are not permanent. After a time specified along with the access token when it was obtained, the access token will become invalid.

See also: Refresh Token

### `[protected]` void QOAuth2AuthorizationCodeFlow::requestAccessToken(const QString &code)

Requests an access token from the received code. The code is received as a response when the user completes a successful authentication in the browser.

### `[override virtual protected]` void QOAuth2AuthorizationCodeFlow::resourceOwnerAuthorization(const QUrl &url, const QVariantMap &parameters = QVariantMap())

Reimplemented from QAbstractOAuth::resourceOwnerAuthorization().

Builds an authentication URL using url and parameters. This function emits an authorizeWithBrowser() signal to require user interaction.

### `[override virtual]` QString QOAuth2AuthorizationCodeFlow::responseType() const

Reimplemented from QAbstractOAuth2::responseType().

Returns the response_type used in QOAuth2AuthorizationCodeFlow; this is fixed to "code" as required in The OAuth 2.0 RFC

### void QOAuth2AuthorizationCodeFlow::setAccessTokenUrl(const QUrl &accessTokenUrl)

Sets the URL used to request the access token to accessTokenUrl.

Note: Setter function for property accessTokenUrl.

See also accessTokenUrl().