daily pastebin goal
7%
SHARE
TWEET

Untitled

a guest Apr 27th, 2018 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. log.info "* Login"
  2.  
  3.         def sf_login_domain = grailsApplication.config.crm.sf_login_domain
  4.         log.debug "**  sf_login_domain: ${sf_login_domain}"
  5.         def consumer_key = grailsApplication.config.crm.consumer_key
  6.         log.debug "**  consumer_key: ${consumer_key}"
  7.         def consumer_secret = grailsApplication.config.crm.consumer_secret
  8.         log.debug "**  consumer_secret: ${consumer_secret}"
  9.         def auth_username = grailsApplication.config.crm.auth_username
  10.         log.debug "**  auth_username: ${auth_username}"
  11.         def auth_password = grailsApplication.config.crm.auth_password
  12.         log.debug "**  auth_password: ${auth_password}"
  13.         def retornoLogin
  14.         def access_token = ""
  15.         def instance_domain = ""
  16.  
  17.         //Request Access_token and instance domain for work
  18.         def http = new HTTPBuilder(sf_login_domain)
  19.         def postBody = [
  20.             grant_type: 'password',
  21.             client_id: consumer_key,
  22.             client_secret: consumer_secret,
  23.             username: auth_username,
  24.             password: auth_password
  25.         ]
  26.         try {
  27.             http.post( path : 'EfetuarLogin',
  28.                 body : postBody,
  29.                 requestContentType: URLENC) { resp, json ->
  30.                     access_token = json.access_token
  31.                     instance_domain = json.instance_url + "/"
  32.             }
  33.             //INSERIR AQUI MEU log.debug "rota ${variavel com a rota}"
  34.             log.debug "**  access_token: ${access_token}, instance_domain: ${instance_domain}"
  35.             coss.Parametro.executeUpdate("update Parametro p set p.valor='$access_token' where p.chave='ACCESS_TOKEN_SALES_FORCE'")
  36.             coss.Parametro.executeUpdate("update Parametro p set p.valor='$instance_domain' where p.chave='INSTANCE_DOMAIN_SALES_FORCE'")
  37.             retornoLogin = ['access_token':access_token, 'instance_domain':instance_domain]
  38.         }
  39.         catch(Exception e){
  40.             log.error "** Error code: ${e}"
  41.             log.error "** Post form: ${postBody}"
  42.         }
  43.         return retornoLogin
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top