Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Desktop app with Facebook OAuth [Qt5.1] [Qt Quick Controls]
Forum Updated to NodeBB v4.3 + New Features

Desktop app with Facebook OAuth [Qt5.1] [Qt Quick Controls]

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Ghost
    wrote on last edited by
    #1

    I am getting confused on how to implement access_token retrieval from Facebook.
    This is how I have thought it out:

    1. An OAuthorizer class, which takes care of the OAuth authentication. It initiates launch of a WebView window which will ask user to authenticate my app. On successful authentication, this class will store and provide a short-lived user access_token provided by Facebook. This class's authorize() method will have to launch QML window, thus involving a bit of UI code.
    2. TokenService class contains methods that retrieves different types of access_tokens based on the short-lived user access_token - like long-lived user access_token, page_token, etc.) This would be a pure C++ class without having to deal with any QML component.

    Here is a rough sketch of the code. Note that it might not be syntactically correct - I wrote it on the fly.
    @
    class OAuthorizer :: QObject
    {
    Q_OBJECT

    public:
    OAuthorizer();
    QString accessToken() const;
    void authorize(); // This method will launch a QML component containing WebView, which will authenticate and emit an authSuccessful signal.

    public slots:
    void onSuccessfulAuth(const QUrl &url); // This slot will be invoked by authSuccessful signal and will parse the redirected URL for short-lived access_token.

    private:
    QString accessToken;
    // Other fields like redirectUrl, facebookAuthUrl, appId.
    }

    class TokenService :: QObject
    {
    Q_OBJECT

    public:
    TokenService();
    QString fetchLongLivedToken(QString shortLivedUserToken);
    QStringList fetchPageTokens(QString userToken);

    private:
    QString longLivedTokenUrl;
    QString pageTokenUrl;
    }
    @

    The part where I have a bad feeling is the OAuthorizer class. It inevitably includes UI-related code inorder to launch a QML window. Is it a good idea/design?

    So I think this design is very much flawed. I would welcome a wholly new, if better design as well as improvements on this one.

    Bhoot

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved