Examples of OAuthException


Examples of com.google.api.ads.common.lib.exception.OAuthException

  private String getOAuth2Header(OAuth2Compatible oAuth2Compatible) throws OAuthException {
    if (adsLibConfiguration.isAutoRefreshOAuth2TokenEnabled()) {
      try {
        oAuth2Helper.refreshCredential(oAuth2Compatible.getOAuth2Credential());
      } catch (IOException e) {
        throw new OAuthException("OAuth2 token could not be refreshed.", e);
      }
    }

    return oAuth2AuthorizationHeaderProvider.getOAuth2AuthorizationHeader(oAuth2Compatible);
  }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

        responseBody = StreamUtil.readString(reader);
      } finally {
        StreamUtil.close(reader);
      }
    } catch (Exception e) {
      throw new OAuthException(e, "getAccessToken failed with Exception: <br>" + e);
    } finally {
      if(content != null) {
        content.close();
      }
    }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

        responseBody = StreamUtil.readString(reader);
      } finally {
        StreamUtil.close(reader);
      }
    } catch (Exception e) {
      throw new OAuthException(e,"getAccessToken failed with Exception: <br>");
    } finally {
      if(content!=null) {
        content.close();
      }
    }
    if (responseCode != HttpStatus.SC_OK) {
      String exceptionDetail = buildErrorMessage(responseCode, responseBody);
      if (exceptionDetail != null) {
        String msg = "Unable to retrieve access token because \"{0}\". Please check the access token URL is valid, current value: {1}.";
        msg = MessageFormat.format(msg, exceptionDetail, getAccessTokenURL());
        throw new OAuthException(null, msg);
      }
    } else {
      setOAuthData(responseBody); //save the returned data
    }
  }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

                          setAccessTokenURL(consumerToken.getAccessTokenUri());
                      }                  
                  }
              }
          } catch (CredentialStoreException cse) {
          throw new OAuthException(cse, cse.getMessage());
      }
        }
    }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

              if(token!=null) {
                  return token;
              }
          }
        } catch (CredentialStoreException cse) {
        throw new OAuthException(cse, "Error finding credentials from the store");
    }
        return null;
    }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

               if(credStore!=null) {
                 // Find the token for this user
                 credStore.remove(getServiceName(), ACCESS_TOKEN_STORE_TYPE, getUserId());
               }
           } catch (CredentialStoreException cse) {
         throw new OAuthException(cse, "Error trying to delete Token.");
       }
        }
    }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

            responseBody = StreamUtil.readString(reader);
          } finally {
            StreamUtil.close(reader);
          }
        } catch (Exception e) {
          throw new OAuthException(e ,"refreshAccessToken failed with Exception: <br>" + e);
        } finally {
          if (method != null){
          try {
            if(content!=null) {
              content.close();
            }
          } catch (IOException e) {
            throw new OAuthException(e ,"refreshAccessToken failed with Exception: <br>" + e);
          }
          }
        }
        if (responseCode != HttpStatus.SC_OK) {
            acquireToken(true, true); // Failed to renew token, get a new one
                  return null;
        } else {
          setOAuthData(responseBody);
          renewedtoken = createToken(getAppId(),getServiceName()); // Now create a new token and save that in the store       
          Context context = Context.get();
          setAccessTokenObject(renewedtoken);
          try {
                if(!context.isCurrentUserAnonymous()) {
                  CredentialStore credStore = findCredentialStore();
                  if (credStore != null) {
                // if the token is already present, and was expired due to which we have fetched a new
                // token, then we remove the token from the store first and then add this new token.
                deleteToken();
                credStore.store(getServiceName(), ACCESS_TOKEN_STORE_TYPE, getUserId(), token);
              }
                  } else {
                    AnonymousCredentialStore.storeCredentials(context, token, getAppId(), getServiceName()); // Store the token for anonymous user
                  }
          } catch (CredentialStoreException cse) {
            throw new OAuthException(cse, "Error trying to renew Token.");
          }
        }
        return renewedtoken;
    }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

    public CredentialStore findCredentialStore() throws OAuthException {
      CredentialStore credStore = null;
    try {
      credStore = CredentialStoreFactory.getCredentialStore(getCredentialStore());
    } catch (CredentialStoreException cse) {
      throw new OAuthException(cse, "Error finding credentials from the store");
    }
    return credStore;
    }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

    public boolean shouldRenewToken(AccessToken token) throws OAuthException {
        // We do not automatically renew/acquire it - we just get it from the store
       if(token==null) {
            token = _findTokenFromStore(Context.get(), null);
            if(token==null) {
                throw new OAuthException(null,"No user token is available");
            }
        }
        return token.isExpired(getExpireThreshold());
    }
View Full Code Here

Examples of com.ibm.sbt.security.authentication.oauth.OAuthException

                        getUserId(),
                        expiresIn,
                        getRefreshToken()
            );
        } catch (Exception e) {
            throw new OAuthException(e);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.