public TokenRequest withNote(String note) { return withNote(note,null); }
public TokenRequest withScopes(String... scopes) { for (String scope : scopes) { withScope(scope); } return this; }
public OauthToken createOAuthClientToken(TokenRequest tokenRequest) throws OauthClientException { try { Map<String,List<String>> params = new HashMap<String, List<String>>(); //access_type 'offline' generates a refresh_token as well params.put("access_type", Collections.singletonList(tokenRequest.getAccessType())); params.put("scope", singletonList(join(tokenRequest.getScopes(), " "))); params.put("grant_type", singletonList("client_credentials")); return bees.formUrlEncoded(gcUrl+"/oauth/token", null, params).bind(OauthToken.class,bees); } catch (IOException e) { throw new OauthClientException("Failed to create OAuth token from OAuth client ID&secret",e); } }
@Override public OauthToken createToken(TokenRequest r) throws OauthClientException { OauthToken t = new OauthToken(); t.accessToken = "account="+r.getAccountName()+",scope="+ join(r.getScopes(), " "); return t; }
public OauthToken createOAuthClientToken(TokenRequest tokenRequest) throws OauthClientException { try { Map<String,List<String>> params = new HashMap<String, List<String>>(); //access_type 'offline' generates a refresh_token as well params.put("access_type", Collections.singletonList(tokenRequest.getAccessType())); params.put("scope", singletonList(join(tokenRequest.getScopes(), " "))); params.put("grant_type", singletonList("client_credentials")); return bees.formUrlEncoded(gcUrl+"/oauth/token", null, params).bind(OauthToken.class,bees); } catch (IOException e) { throw new OauthClientException("Failed to create OAuth token from OAuth client ID&secret",e); } }
public TokenRequest withScopes(String... scopes) { for (String scope : scopes) { withScope(scope); } return this; }
public TokenRequest withNote(String note) { return withNote(note,null); }
/** * * Create a Json serializable Oauth token request. * * @param note optional. Tells something about the oauth application * @param noteUrl optional. Your application URL * @param refreshToken optional. Refresh token that should be used to generate a new token. * @param accountName required. Name of the account * @param scopes Optional. array of scopes to be granted with this token. The default scope is https://api.cloudbees.com/v2/users/user, * which is user read and write scope. If you are creating token to crete other tokens with specific scopes you must ask for * https://api.cloudbees.com/v2/users/user/generate_token scope scope. * * @throws IllegalArgumentException In case there is an error */ public TokenRequest(String note, String noteUrl, String refreshToken, String accountName, String... scopes) { this.note = note; this.noteUrl = noteUrl; this.accountName = accountName; this.refreshToken = refreshToken; for(String scope: scopes) withScope(scope); }
/** * * Create a Json serializable Oauth token request. * * @param note optional. Tells something about the oauth application * @param noteUrl optional. Your application URL * @param refreshToken optional. Refresh token that should be used to generate a new token. * @param accountName required. Name of the account * @param scopes Optional. array of scopes to be granted with this token. The default scope is https://api.cloudbees.com/v2/users/user, * which is user read and write scope. If you are creating token to crete other tokens with specific scopes you must ask for * https://api.cloudbees.com/v2/users/user/generate_token scope scope. * * @throws IllegalArgumentException In case there is an error */ public TokenRequest(String note, String noteUrl, String refreshToken, String accountName, String... scopes) { this.note = note; this.noteUrl = noteUrl; this.accountName = accountName; this.refreshToken = refreshToken; for(String scope: scopes) withScope(scope); }
public TokenRequest withScope(CloudResource res, Capability capability) { return withScope(capability.to(res)); }
public TokenRequest withScope(URL cloudResource, Capability capability) { return withScope(capability.to(cloudResource)); }
public TokenRequest withScope(URL cloudResource, Capability capability) { return withScope(capability.to(cloudResource)); }
public TokenRequest withScope(CloudResource res, Capability capability) { return withScope(capability.to(res)); }