Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.paypal.api.openidconnect;
  
  import java.util.HashMap;
  import java.util.Map;
  
Class Tokeninfo
 
 public class Tokeninfo extends PayPalResource {

OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED.
 
 	private String scope;

The access token issued by the authorization server.
 
 	private String accessToken;

The refresh token, which can be used to obtain new access tokens using the same authorization grant as described in OAuth2.0 RFC6749 in Section 6.
 
 	private String refreshToken;

The type of the token issued as described in OAuth2.0 RFC6749 (Section 7.1). Value is case insensitive.
 
 	private String tokenType;

The lifetime in seconds of the access token.
 
 	private Integer expiresIn;

APP ID associated with this token
 
 	private String appId;

Default Constructor
 
 	public Tokeninfo() {
 	}

Parameterized Constructor
 
 	public Tokeninfo(String accessTokenString tokenTypeInteger expiresIn) {
 		this. = accessToken;
 		this. = tokenType;
 		this. = expiresIn;
 	}

Setter for scope
 
 	public void setScope(String scope) {
 		this. = scope;
 	}

Getter for scope
 
 	public String getScope() {
 		return this.;
 	}

Setter for accessToken
 
 	public void setAccessToken(String accessToken) {
 		this. = accessToken;
 	}

Getter for just accessToken without type (e.g., "EEwJ6tF9x5WCIZDYzyZGaz6Khbw7raYRIBV_WxVvgmsG")
 
 	public String getAccessToken() {
 		return this.;
 	}

Getter for accessToken with token type (e.g., "Bearer: EEwJ6tF9x5WCIZDYzyZGaz6Khbw7raYRIBV_WxVvgmsG")
		return this. + " " + this.;
	}

Setter for refreshToken
	public void setRefreshToken(String refreshToken) {
		this. = refreshToken;
	}

Getter for refreshToken
	public String getRefreshToken() {
		return this.;
	}

Setter for tokenType
	public void setTokenType(String tokenType) {
		this. = tokenType;
	}

Getter for tokenType
	public String getTokenType() {
		return this.;
	}

Setter for expiresIn
	public void setExpiresIn(Integer expiresIn) {
		this. = expiresIn;
	}

Getter for expiresIn
	public Integer getExpiresIn() {
		return this.;
	}

Setter for appId
	public void setAppId(String appId) {
		this. = appId;
	}

Getter for appId
	public String getAppId() {
		return this.;
	}

Creates an Access Token from an Authorization Code.

Parameters:
createFromAuthorizationCodeParameters Query parameters used for API call
Returns:
Tokeninfo
Throws:
com.paypal.base.rest.PayPalRESTException
			CreateFromAuthorizationCodeParameters createFromAuthorizationCodeParameters)
				createFromAuthorizationCodeParameters);
	}

Creates an Access Token from an Authorization Code.

Parameters:
apiContext com.paypal.base.rest.APIContext to be used for the call.
createFromAuthorizationCodeParameters Query parameters used for API call
Returns:
Tokeninfo
Throws:
com.paypal.base.rest.PayPalRESTException
			APIContext apiContext,
			CreateFromAuthorizationCodeParameters createFromAuthorizationCodeParameters)
		String pattern = "v1/identity/openidconnect/tokenservice?grant_type={0}&code={1}&redirect_uri={2}";
		Object[] parameters = new Object[] { createFromAuthorizationCodeParameters };
		String resourcePath = RESTUtil.formatURIPath(patternparameters);
		return createFromAuthorizationCodeParameters(apiContextcreateFromAuthorizationCodeParametersresourcePath);
	}

Creates an Access and a Refresh Tokens from an Authorization Code for future payment.

Parameters:
apiContext com.paypal.base.rest.APIContext to be used for the call.
createFromAuthorizationCodeParameters Query parameters used for API call
Returns:
Tokeninfo
Throws:
com.paypal.base.rest.PayPalRESTException
			APIContext apiContext,
			CreateFromAuthorizationCodeParameters createFromAuthorizationCodeParameters)
		String pattern = "v1/oauth2/token?grant_type=authorization_code&response_type=token&redirect_uri=urn:ietf:wg:oauth:2.0:oob&code={0}";
		Object[] parameters = new Object[] { createFromAuthorizationCodeParameters.getContainerMap().get("code") };
		String resourcePath = RESTUtil.formatURIPath(patternparameters);
		if (apiContext.getHTTPHeaders() == null) {
			apiContext.setHTTPHeaders(new HashMap<StringString>());
		}
		return createFromAuthorizationCodeParameters(apiContextcreateFromAuthorizationCodeParametersresourcePath);
	}
			APIContext apiContext,
			CreateFromAuthorizationCodeParameters createFromAuthorizationCodeParameters,
			String resourcePath)
		String payLoad = resourcePath.substring(resourcePath.indexOf('?') + 1);
		resourcePath = resourcePath.substring(0, resourcePath.indexOf('?'));
		Map<StringStringheadersMap = new HashMap<StringString>();
		if (apiContext == null) {
			apiContext = new APIContext();
		}
		apiContext.setMaskRequestId(true);
		if (createFromAuthorizationCodeParameters.getClientID() == null
				|| createFromAuthorizationCodeParameters.getClientID().trim()
						.length() <= 0
				|| createFromAuthorizationCodeParameters.getClientSecret() == null
				|| createFromAuthorizationCodeParameters.getClientSecret()
						.trim().length() <= 0) {
					"ClientID and ClientSecret not set in CreateFromAuthorizationCodeParameters");
else {
			OAuthTokenCredential oauthTokenCredential = new OAuthTokenCredential(
					createFromAuthorizationCodeParameters.getClientID(),
					createFromAuthorizationCodeParameters.getClientSecret(),
					apiContext.getConfigurationMap());
			String authorizationHeader = oauthTokenCredential
			headersMap.put(.authorizationHeader);
		}
		apiContext.setHTTPHeaders(headersMap);
		return configureAndExecute(apiContext.,
				resourcePathpayLoadTokeninfo.class);
	}

Creates an Access Token from an Refresh Token.

Parameters:
createFromRefreshTokenParameters Query parameters used for API call
Returns:
Tokeninfo
Throws:
com.paypal.base.rest.PayPalRESTException
			CreateFromRefreshTokenParameters createFromRefreshTokenParameters)
		return createFromRefreshToken(nullcreateFromRefreshTokenParameters);
	}

Creates an Access Token from an Refresh Token.

Parameters:
apiContext com.paypal.base.rest.APIContext to be used for the call.
createFromRefreshTokenParameters Query parameters used for API call
Returns:
Tokeninfo
Throws:
com.paypal.base.rest.PayPalRESTException
			CreateFromRefreshTokenParameters createFromRefreshTokenParameters)
		String pattern = "v1/identity/openidconnect/tokenservice?grant_type={0}&refresh_token={1}&scope={2}&client_id={3}&client_secret={4}";
		Map<StringStringparamsMap = new HashMap<StringString>();
		paramsMap.putAll(createFromRefreshTokenParameters.getContainerMap());
		try {
			paramsMap.put("refresh_token", URLEncoder.encode(getRefreshToken(),
			// Ignore
		}
		Object[] parameters = new Object[] { paramsMap };
		String resourcePath = RESTUtil.formatURIPath(patternparameters);
		String payLoad = resourcePath.substring(resourcePath.indexOf('?') + 1);
		resourcePath = resourcePath.substring(0, resourcePath.indexOf('?'));
		if (apiContext == null) {
			apiContext = new APIContext();
		}
		apiContext.setMaskRequestId(true);
		Map<StringStringheadersMap = new HashMap<StringString>();
		if (createFromRefreshTokenParameters.getClientID() == null
				|| createFromRefreshTokenParameters.getClientID().trim()
						.length() <= 0
				|| createFromRefreshTokenParameters.getClientSecret() == null
				|| createFromRefreshTokenParameters.getClientSecret()
						.trim().length() <= 0) {
					"ClientID and ClientSecret not set in CreateFromRefreshTokenParameters");
else {
			OAuthTokenCredential oauthTokenCredential = new OAuthTokenCredential(
					createFromRefreshTokenParameters.getClientID(),
					createFromRefreshTokenParameters.getClientSecret(),
					apiContext.getConfigurationMap());
			String authorizationHeader = oauthTokenCredential
			headersMap.put(.authorizationHeader);
		}
		apiContext.setHTTPHeaders(headersMap);
		return configureAndExecute(apiContext.,
				resourcePathpayLoadTokeninfo.class);
	}

Creates an Access Token from an Refresh Token for future payment.

Parameters:
apiContext com.paypal.base.rest.APIContext to be used for the call.
Returns:
Tokeninfo
Throws:
com.paypal.base.rest.PayPalRESTException
		if (getRefreshToken() == null || getRefreshToken().equals("")) {
			throw new PayPalRESTException("refresh token is empty");
		}
		String pattern = "v1/oauth2/token?grant_type=refresh_token&refresh_token={0}";
		Map<StringStringparamsMap = new HashMap<StringString>();
		try {
			paramsMap.put("refresh_token", URLEncoder.encode(getRefreshToken(),
			// Ignore
		}
		Object[] parameters = new Object[] { paramsMap };
		String resourcePath = RESTUtil.formatURIPath(patternparameters);
		String payLoad = resourcePath.substring(resourcePath.indexOf('?') + 1);
		resourcePath = resourcePath.substring(0, resourcePath.indexOf('?'));
		if (apiContext == null) {
			apiContext = new APIContext();
		}
		apiContext.setMaskRequestId(true);
		Map<StringStringheadersMap = new HashMap<StringString>();
		apiContext.setHTTPHeaders(headersMap);
		return configureAndExecute(apiContext.,
				resourcePathpayLoadTokeninfo.class);
	}
New to GrepCode? Check out our FAQ X