当前位置: 首页>>代码示例>>Java>>正文


Java GoogleAuthorizationCodeRequestUrl.build方法代码示例

本文整理汇总了Java中com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl.build方法的典型用法代码示例。如果您正苦于以下问题:Java GoogleAuthorizationCodeRequestUrl.build方法的具体用法?Java GoogleAuthorizationCodeRequestUrl.build怎么用?Java GoogleAuthorizationCodeRequestUrl.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl的用法示例。


在下文中一共展示了GoogleAuthorizationCodeRequestUrl.build方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。