Get it from githubaykev has modified it for Chrome compatibility hereNote:
This library is not yet finished! It does not yet implement the import methods, and the majority of its functions have not been tested yet. I have currently only tested bookmark/folder retrieval, creation, and trashing. If you find things that don't work, please tell me.
First, include operalink.js, oauth.js, and sha1.js. If your extension isn't already requesting access for all domains, add the following to your config.xml.
<access origin="https://auth.opera.com" />
<access origin="https://link.api.opera.com" />
All Opera Link functions can be accessed from the opera.link object. Functions for specific data types are found in the opera.link.<datatype> objects.
Check background.js for an example that uses the library. It first defines two variables: tempToken and authorized. "tempToken" will be used during the authentication process while we are waiting for the user to grant our application access to Opera Link. "authorized' keeps track of whether we have the proper credentials to access Link. If not authorized, clicking the extension's button will start the authentication process. Otherwise, it will run tests on the library functions.
After registering your application with Opera's OAuth endpoint
, you will get a consumer key and consumer secret. Call opera.link.consumer()
with those two values before using any other Opera Link functions.
Next, if the user has previously granted access to your application and you have saved the access token and secret, you can load those (automatically handled by opera.link.loadToken()
) and check whether they are still valid using opera.link.testAuthorization()
. If the callback function is called with "true", we are authorized and don't need to do anything else. Otherwise, we need to get an access token.
To get an access token, first call opera.link.requestToken()
. This will generate a temporary token and secret (which I store in tempToken in the example) which are used in the next step, and it will open a new tab where the user can grant your application permission to access his/her data. After accepting, the user is given a 6-digit verification code. Call opera.link.getAccessToken()
with the temporary token, secret, and the verification code to get a permanent access token. The example uses the getverifier.js include script to automatically get the verifier code. It also uses opera.link.saveToken()
to store the access token so it can be loaded the next time the extension is started.
Once we have access to Opera Link, we can start getting data from it and modifying things. Read the Opera Link API documentation
. Each of the methods here just sends one type of request defined there.
Use these objects to access each of the data types:
There is also a documentation file in the jsdoc folder. It explains all of the available functions.Edit 5/4:
Just found a fork by aykev for Chrome compatibility. Added a link up top. Sentence fragments.
I have finals over the next few days, so any updates will come after those are over.