コード例 #1
0
  /**
   * Obtains OAuth access tokens which can be used during entire communication process with Opera
   * Link server and invokes first synchronisation
   */
  public void grantAccess() {

    Uri uri = this.getIntent().getData();
    if (uri == null) {
      return;
    }

    String verifier = uri.getQueryParameter(LinkClient.OAUTH_VERIFIER);
    if (verifier == null) {
      return;
    }
    try {
      link.grantAccess(verifier);
      Log.i(SYNC_TAG, "Access granted");

      accessToken = link.getAccessToken();
      tokenSecret = link.getTokenSecret();
      Editor prefEditor = pref.edit();
      prefEditor.putString(ACCESS_TOKEN_PREF_KEY, accessToken);
      prefEditor.putString(TOKEN_SECRET_PREF_KEY, tokenSecret);

      prefEditor.commit();
      isConnected = true;

      syncItems();
    } catch (LinkAccessDeniedException e) {
      showToast("Access forbidden for access token " + accessToken);
      e.printStackTrace();
    } catch (LibOperaLinkException e) {
      e.printStackTrace();
    }
  }