本文整理汇总了Java中com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl.setState方法的典型用法代码示例。如果您正苦于以下问题:Java AuthorizationCodeRequestUrl.setState方法的具体用法?Java AuthorizationCodeRequestUrl.setState怎么用?Java AuthorizationCodeRequestUrl.setState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl
的用法示例。
在下文中一共展示了AuthorizationCodeRequestUrl.setState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authorizationRequestUri
import com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl; //导入方法依赖的package包/类
/**
* Generates the authorization request URI for the client credentials.
* @param redirectionEndpoint redirection endpoint for the authorization
* and token requests; if this value is <code>null</code>, the
* <code>redirect_uri</code> parameter shall not be included.
* @param state opaque state string for the authorization request; if this
* argument is <code>null</code>, the <code>state</code> parameter shall
* not be used
* @return authorization request URI
* @throws NullPointerException if this object had no client credentials
* @since 5.0
*/
public String authorizationRequestUri(
URI redirectionEndpoint, String state) {
redirectionEndpointUri = null;
if (redirectionEndpoint != null) {
redirectionEndpointUri = redirectionEndpoint.toString();
}
AuthorizationCodeFlow flow = getAuthorizationCodeFlow(false);
AuthorizationCodeRequestUrl request = flow.newAuthorizationUrl();
if (redirectionEndpointUri != null) {
request.setRedirectUri(redirectionEndpointUri);
}
if (state != null) {
request.setState(state);
}
return request.build();
}
示例2: getAuthenticateUrl
import com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl; //导入方法依赖的package包/类
/**
* Create authentication URL.
*
* @param requestUrl URL of current HTTP request. This parameter required to be able determine URL
* for redirection after authentication. If URL contains query parameters they will be copy to
* 'state' parameter and returned to callback method.
* @param scopes specify exactly what type of access needed
* @return URL for authentication
*/
public String getAuthenticateUrl(URL requestUrl, List<String> scopes)
throws OAuthAuthenticationException {
if (!isConfigured()) {
throw new OAuthAuthenticationException("Authenticator is not configured");
}
AuthorizationCodeRequestUrl url =
flow.newAuthorizationUrl().setRedirectUri(findRedirectUrl(requestUrl)).setScopes(scopes);
url.setState(prepareState(requestUrl));
return url.build();
}
示例3: onAuthorization
import com.google.api.client.auth.oauth2.AuthorizationCodeRequestUrl; //导入方法依赖的package包/类
@Override
protected void onAuthorization(HttpServletRequest req,
HttpServletResponse resp,
AuthorizationCodeRequestUrl authorizationUrl)
throws ServletException, IOException {
authorizationUrl.setState(req.getParameter("state"));
super.onAuthorization(req, resp, authorizationUrl);
}