本文整理汇总了Java中com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl类的典型用法代码示例。如果您正苦于以下问题:Java GoogleAuthorizationCodeRequestUrl类的具体用法?Java GoogleAuthorizationCodeRequestUrl怎么用?Java GoogleAuthorizationCodeRequestUrl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GoogleAuthorizationCodeRequestUrl类属于com.google.api.client.googleapis.auth.oauth2包,在下文中一共展示了GoogleAuthorizationCodeRequestUrl类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: openBrowserAndGetToken
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; //导入依赖的package包/类
private void openBrowserAndGetToken() {
// Step 1: Authorize -->
String authorizationUrl = new GoogleAuthorizationCodeRequestUrl(
CLIENT_ID, REDIRECT_URI, SCOPES).build();
try {
// Point or redirect your user to the authorizationUrl.
java.awt.Desktop.getDesktop().browse(new URI(authorizationUrl));
} catch (Exception e) {
LOGGER.warning("Unable to open browser: " + e.toString());
LOGGER.info("Go to: " + authorizationUrl);
JOptionPane.showMessageDialog(optionsFrame, "Cannot open browser. Check the console for the necessary URL.",
"Error", JOptionPane.ERROR_MESSAGE);
}
// End of Step 1 <--
}
开发者ID:sih4sing5hong5,项目名称:google-sites-liberation,代码行数:16,代码来源:GuiMain.java
示例2: ask
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; //导入依赖的package包/类
@RequestMapping(value = "/ask", method = RequestMethod.GET)
public void ask(HttpServletResponse response) throws IOException {
// Step 1: Authorize --> ask for auth code
String url = new GoogleAuthorizationCodeRequestUrl(connection.getClientSecrets(),
connection.getRedirectUrl(), Global.SCOPES)
// .setApprovalPrompt("auto")
.setApprovalPrompt("force")
.build();
System.out.println("Go to the following link in your browser: ");
System.out.println(url);
response.sendRedirect(url);
}
开发者ID:webcane,项目名称:google-spreadsheet-api-samples,代码行数:16,代码来源:GoogleAuthorizationController.java
示例3: obtainVerificationCodeFromUserInteraction
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; //导入依赖的package包/类
@Override
public String obtainVerificationCodeFromUserInteraction(
String title, GoogleAuthorizationCodeRequestUrl authCodeRequestUrl) {
GoogleLoginCopyAndPasteDialog dialog =
new GoogleLoginCopyAndPasteDialog(
authCodeRequestUrl,
AccountMessageBundle.message("login.service.copyandpaste.title.text"));
dialog.show();
if (dialog.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) {
return null;
}
return Strings.emptyToNull(dialog.getVerificationCode());
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:15,代码来源:IntegratedIntellijGoogleLoginService.java
示例4: GoogleLoginCopyAndPasteDialog
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; //导入依赖的package包/类
/** Initialize the verification code dialog. */
public GoogleLoginCopyAndPasteDialog(
GoogleAuthorizationCodeRequestUrl requestUrl, String message) {
super(true);
urlString = requestUrl.build();
if (message != null) {
setTitle(message);
} else {
setTitle(TITLE);
}
init();
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:15,代码来源:GoogleLoginCopyAndPasteDialog.java
示例5: getAuthorizationUrl
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; //导入依赖的package包/类
/**
* Retrieve the authorization URL.
*
* @param emailAddress User's e-mail address.
* @param state State for the authorization URL.
* @return Authorization URL to redirect the user to.
* @throws IOException Unable to load client_secrets.json.
*/
public static String getAuthorizationUrl(String emailAddress,
String state) throws IOException {
GoogleAuthorizationCodeRequestUrl urlBuilder = getFlow()
.newAuthorizationUrl().setRedirectUri(REDIRECT_URI)
.setState(state);
urlBuilder.set("user_id", emailAddress);
return urlBuilder.build();
}
开发者ID:mba811,项目名称:loli.io,代码行数:17,代码来源:GDriveAPI.java
示例6: getRefreshToken
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; //导入依赖的package包/类
@SuppressWarnings("unused")
private static String getRefreshToken() throws IOException {
String client_id = System.getenv("PICASSA_CLIENT_ID");
String client_secret = System.getenv("PICASSA_CLIENT_SECRET");
// Adapted from http://stackoverflow.com/a/14499390/1447621
String redirect_uri = "http://localhost";
String scope = "http://picasaweb.google.com/data/";
List<String> scopes;
HttpTransport transport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();
scopes = new LinkedList<String>();
scopes.add(scope);
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(transport, jsonFactory, client_id, client_secret, scopes).build();
GoogleAuthorizationCodeRequestUrl url = flow.newAuthorizationUrl();
url.setRedirectUri(redirect_uri);
url.setApprovalPrompt("force");
url.setAccessType("offline");
String authorize_url = url.build();
// paste into browser to get code
System.out.println("Put this url into your browser and paste in the access token:");
System.out.println(authorize_url);
Scanner scanner = new Scanner(System.in);
String code = scanner.nextLine();
scanner.close();
flow = new GoogleAuthorizationCodeFlow.Builder(transport, jsonFactory, client_id, client_secret, scopes).build();
GoogleTokenResponse res = flow.newTokenRequest(code).setRedirectUri(redirect_uri).execute();
String refreshToken = res.getRefreshToken();
String accessToken = res.getAccessToken();
System.out.println("refresh:");
System.out.println(refreshToken);
System.out.println("access:");
System.out.println(accessToken);
return refreshToken;
}
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:41,代码来源:ImageUtils.java
示例7: getAuthorizationUrl
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; //导入依赖的package包/类
/**
* Generates a consent page url.
* @return A consent page url string for user redirection.
*/
public String getAuthorizationUrl() {
GoogleAuthorizationCodeRequestUrl urlBuilder =
new GoogleAuthorizationCodeRequestUrl(
clientSecrets.getWeb().getClientId(),
clientSecrets.getWeb().getRedirectUris().get(0), SCOPES);;
return urlBuilder.build();
}
开发者ID:googlearchive,项目名称:drivemarks,代码行数:12,代码来源:CredentialManager.java
示例8: obtainVerificationCodeFromUserInteraction
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; //导入依赖的package包/类
@Override
public String obtainVerificationCodeFromUserInteraction(
String title, GoogleAuthorizationCodeRequestUrl authCodeRequestUrl) {
throw new RuntimeException("Not to be called."); //$NON-NLS-1$
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:6,代码来源:LoginServiceUi.java
示例9: getGoogleLoginUrl
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; //导入依赖的package包/类
/**
* Returns a URL through which users can login.
*
* @param redirectUrl URL to which the login result is directed. For example, a local web
* server listening on the URL can receive an authorization code from it.
*/
public static String getGoogleLoginUrl(String redirectUrl) {
return new GoogleAuthorizationCodeRequestUrl(Constants.getOAuthClientId(), redirectUrl,
GoogleLoginService.OAUTH_SCOPES).toString();
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:11,代码来源:GoogleLoginService.java
示例10: execute
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl; //导入依赖的package包/类
public String execute(
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
WebKeys.THEME_DISPLAY);
String cmd = ParamUtil.getString(request, Constants.CMD);
String redirectUri = PortalUtil.getPortalURL(request) + _REDIRECT_URI;
if (cmd.equals("login")) {
GoogleAuthorizationCodeFlow flow = getFlow();
GoogleAuthorizationCodeRequestUrl
googleAuthorizationCodeRequestUrl = flow.newAuthorizationUrl();
googleAuthorizationCodeRequestUrl.setRedirectUri(redirectUri);
String url = googleAuthorizationCodeRequestUrl.build();
response.sendRedirect(url);
}
else if (cmd.equals("token")) {
HttpSession session = request.getSession();
String code = ParamUtil.getString(request, "code");
if (Validator.isNotNull(code)) {
Credential credential = exchangeCode(code, redirectUri);
Userinfo userinfo = getUserInfo(credential);
User user = setGoogleCredentials(
session, themeDisplay.getCompanyId(), userinfo);
if ((user != null) &&
(user.getStatus() == WorkflowConstants.STATUS_INCOMPLETE)) {
redirectUpdateAccount(request, response, user);
return null;
}
PortletURL portletURL = PortletURLFactoryUtil.create(
request, PortletKeys.FAST_LOGIN, themeDisplay.getPlid(),
PortletRequest.RENDER_PHASE);
portletURL.setWindowState(LiferayWindowState.POP_UP);
portletURL.setParameter(
"struts_action", "/login/login_redirect");
response.sendRedirect(portletURL.toString());
}
}
return null;
}
开发者ID:sergiogonzalez,项目名称:google-login-hook,代码行数:60,代码来源:GoogleOAuth.java
注:本文中的com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论