Amber Web Authorization Framework
API DocumentationOAuth10a QML Type
A helper for OAuth10a flows. More...
Import Statement: | import Amber.Web.Authorization 1.0 |
Properties
- accessTokenEndpoint : string
- authorizeTokenEndpoint : string
- consumerKey : string
- consumerSecret : string
- customParameters : string
- redirectUri : string
- requestTokenEndpoint : string
- timeout : int
- userAgent : string
Signals
- errorOccurred(var code, var message)
- receivedAccessToken(string oauthToken, string oauthSecret)
- receivedAuthorizationCode(string oauthToken, string oauthVerifier)
- receivedTemporaryToken(string oauthToken, string oauthSecret)
Methods
- authorizationUrl(string oauthToken)
- requestTemporaryToken()
Detailed Description
This helper type provides a simple API to allow the client application to request an access token from the remote OAuth10a-enabled service.
It integrates an OAuth1 helper and a RedirectListener helper, and exposes the various properties which are required for the OAuth10a flow.
Example of use:
import QtQml 2.0 import Amber.Web.Authorization 1.0 OAuth10a { id: twitterOAuth property var xhr consumerKey: "" // use your app's consumer_key value consumerSecret: "" // use your app's consumer_secret value requestTokenEndpoint: "https://api.twitter.com/oauth/request_token" authorizeTokenEndpoint: "https://api.twitter.com/oauth/authorize" accessTokenEndpoint: "https://api.twitter.com/oauth/access_token" onErrorOccurred: console.log("Twitter OAuth1 Error: " + error.code + " = " + error.message + " : " + error.httpCode) onReceivedTemporaryToken: { console.log("Got temporary token: " + oauthToken) authorizeInBrowser(oauthToken, oauthTokenSecret) } onReceivedAccessToken: { console.log("Got access token: " + oauthToken + "; " + oauthTokenSecret) xhr = authenticatedRequest("GET", "https://api.twitter.com/1.1/account/verify_credentials.json", oauth1.generateAuthorizationHeader( oauthToken, oauthTokenSecret, "GET", "https://api.twitter.com/1.1/account/verify_credentials.json")) } function authenticatedRequest(method, url, authorization) { var req = new XMLHttpRequest() req.onreadystatechange = function() { if (req.readyState == XMLHttpRequest.DONE) { var response = req.responseText console.log(response) } } req.open(method, url) req.setRequestHeader("Authorization", authorization) req.send() return req } Component.onCompleted: twitterOAuth.requestTemporaryToken() }
See also OAuth1 and RedirectListener.
Property Documentation
The accessTokenEndpoint
value for the integrated OAuth1 helper.
It is a mandatory property.
The authorizeTokenEndpoint
value for the integrated OAuth1 helper.
It is a mandatory property.
The consumerKey
value for the integrated OAuth1 helper.
It is a mandatory property.
The consumerSecret
value for the integrated OAuth1 helper.
It is a mandatory property.
The redirectUri
value for the integrated OAuth1 helper.
By default, it is bound to the uri
value of the integrated RedirectListener helper, but the client application can set it to another URI if it is handling redirects manually.
It is a mandatory property.
The requestTokenEndpoint
value for the integrated OAuth1 helper.
It is a mandatory property.
The timeout
value for the integrated RedirectListener helper.
It is an optional property.
The userAgent
value for the integrated OAuth1 helper.
It is an optional property.
Signal Documentation
This signal is emitted if an error occurs during the OAuth1 flow.
This signal is emitted after receiving the access token and secret from the server.
This signal is emitted after receiving the verifier code for the temporary token from the server.
This signal is emitted after receiving the temporary token and secret from the server.
Method Documentation
Returns a valid authorization URL which can be loaded in the system web browser.
If the redirectUri is not manually specified by the client, the helper will automatically use the integrated RedirectListener helper and ensure that it starts listening.