當前位置: 首頁>>代碼示例>>Java>>正文


Java AuthRequest類代碼示例

本文整理匯總了Java中com.google.api.gwt.oauth2.client.AuthRequest的典型用法代碼示例。如果您正苦於以下問題:Java AuthRequest類的具體用法?Java AuthRequest怎麽用?Java AuthRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AuthRequest類屬於com.google.api.gwt.oauth2.client包,在下文中一共展示了AuthRequest類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addFoursquareAuth

import com.google.api.gwt.oauth2.client.AuthRequest; //導入依賴的package包/類
private void addFoursquareAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Foursquare");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(FOURSQUARE_AUTH_URL, FOURSQUARE_CLIENT_ID);
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
開發者ID:chetsmartboy,項目名稱:gwt-oauth2,代碼行數:26,代碼來源:OAuth2SampleEntryPoint.java

示例2: addDailymotionAuth

import com.google.api.gwt.oauth2.client.AuthRequest; //導入依賴的package包/類
private void addDailymotionAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Dailymotion");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(DAILYMOTION_AUTH_URL, DAILYMOTION_CLIENT_ID);
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
開發者ID:chetsmartboy,項目名稱:gwt-oauth2,代碼行數:26,代碼來源:OAuth2SampleEntryPoint.java

示例3: addWindowsLiveAuth

import com.google.api.gwt.oauth2.client.AuthRequest; //導入依賴的package包/類
private void addWindowsLiveAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Windows Live");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(WINDOWS_LIVE_AUTH_URL, WINDOWS_LIVE_CLIENT_ID)
          .withScopes(WINDOWS_LIVE_BASIC_SCOPE);
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
開發者ID:chetsmartboy,項目名稱:gwt-oauth2,代碼行數:27,代碼來源:OAuth2SampleEntryPoint.java

示例4: requestAuth

import com.google.api.gwt.oauth2.client.AuthRequest; //導入依賴的package包/類
/**
 * Request auth for the given service and scopes, and notify the callback when complete.
 *
 * @param service Service for which auth is being requested.
 * @param scopes Scopes which the user is requesting access to.
 * @param callback Receiver which should be notified when there is a failure.
 * @throws RuntimeException when an exception occurs completing the auth.
 */
public void requestAuth(
    final ApiService service, final Set<String> scopes, final AuthCompleteCallback callback) {

  // TODO(jasonhall): Show some indication that auth is in progress here.
  String[] scopeArray = scopes.toArray(new String[] {});
  AuthRequest req = new AuthRequest(Config.AUTH_URL, Config.CLIENT_ID).withScopes(scopeArray);

  Auth.get().login(req, new Callback<String, Throwable>() {
    @Override
    public void onSuccess(String tokenString) {
      AuthToken token = new AuthToken(tokenString, scopes);
      authTokens.put(service, token);
      callback.complete(token);
    }

    @Override
    public void onFailure(Throwable caught) {
      // When this occurs the UI is left unchanged and the user is allowed to retry the auth
      // request by clicking the toggle again.
      throw new RuntimeException(caught);
    }
  });
}
 
開發者ID:showlowtech,項目名稱:google-apis-explorer,代碼行數:32,代碼來源:AuthManager.java

示例5: addGoogleAuth

import com.google.api.gwt.oauth2.client.AuthRequest; //導入依賴的package包/類
private void addGoogleAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Google");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(GOOGLE_AUTH_URL, GOOGLE_CLIENT_ID)
          .withScopes(PLUS_ME_SCOPE);

      // Calling login() will display a popup to the user the first time it is
      // called. Once the user has granted access to the application,
      // subsequent calls to login() will not display the popup, and will
      // immediately result in the callback being given the token to use.
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
開發者ID:chetsmartboy,項目名稱:gwt-oauth2,代碼行數:32,代碼來源:OAuth2SampleEntryPoint.java

示例6: addInstagramAuth

import com.google.api.gwt.oauth2.client.AuthRequest; //導入依賴的package包/類
private void addInstagramAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Instagram");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(INSTAGRAM_AUTH_URL, INSTAGRAM_CLIENT_ID)
          .withScopes(INSTAGRAM_COMMENTS_SCOPE, INSTAGRAM_LIKES_SCOPE)
          // Instagram expects a plus-delimited list of scopes
          .withScopeDelimiter("+");
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
開發者ID:chetsmartboy,項目名稱:gwt-oauth2,代碼行數:29,代碼來源:OAuth2SampleEntryPoint.java

示例7: addFacebookAuth

import com.google.api.gwt.oauth2.client.AuthRequest; //導入依賴的package包/類
private void addFacebookAuth() {
  // Since the auth flow requires opening a popup window, it must be started
  // as a direct result of a user action, such as clicking a button or link.
  // Otherwise, a browser's popup blocker may block the popup.
  Button button = new Button("Authenticate with Facebook");
  button.addClickHandler(new ClickHandler() {
    @Override
    public void onClick(ClickEvent event) {
      final AuthRequest req = new AuthRequest(FACEBOOK_AUTH_URL, FACEBOOK_CLIENT_ID)
          .withScopes(FACEBOOK_EMAIL_SCOPE, FACEBOOK_BIRTHDAY_SCOPE)
          // Facebook expects a comma-delimited list of scopes
          .withScopeDelimiter(",");
      AUTH.login(req, new Callback<String, Throwable>() {
        @Override
        public void onSuccess(String token) {
          Window.alert("Got an OAuth token:\n" + token + "\n"
              + "Token expires in " + AUTH.expiresIn(req) + " ms\n");
        }

        @Override
        public void onFailure(Throwable caught) {
          Window.alert("Error:\n" + caught.getMessage());
        }
      });
    }
  });
  RootPanel.get().add(button);
}
 
開發者ID:chetsmartboy,項目名稱:gwt-oauth2,代碼行數:29,代碼來源:OAuth2SampleEntryPoint.java


注:本文中的com.google.api.gwt.oauth2.client.AuthRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。