本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
});
}
示例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);
}
示例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);
}
示例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);
}