發表文章

目前顯示的是有「connected app」標籤的文章

Connected App/User 以及 Production 與 Sandbox 交錯複雜的通用關係

情境說明  先上個 Python Sample Code,再容我慢慢解釋: import requests from simple_salesforce import Salesforce PROD_password = '<PROD_password>' PROD_security_token = '<PROD_security_token>' PROD_url = 'https://login.salesforce.com/services/oauth2/token'   STG_password = '<STG_password>' STG_security_token = '<STG_security_token>' STG_url = 'https://test.salesforce.com/services/oauth2/token'     prodSecretKeyWith_ProdUsernamePassword = [ ( 'grant_type' , 'password' ) , ( 'client_id' , '<Production Connected App Client Id>' ) , #PROD ( 'client_secret' , '<Production Connected App Client Secret>' ) , #PROD ( 'username' , 'api@salesforce-note.com' ) , #PROD ( 'password' , '{}{}' . format ( PROD_password , PROD_security_token ) ) , ( 'instance_url' , 'https://salesforce-n...

關於Sandbox Refresh時 、Password、Security Token、Connected App的幾個實證結果

#背景說明 每次 Sandbox Refresh,總是要花一點時間重建 integration。在此紀錄一下幾個容易忘記的重點。 #Sandbox Refresh重點 user email需要手動重新改回 valid 的 email address。 剛 refresh 完成的時候,user 的 password 和 security token 都會保持跟 Production 一致。 Connect App 的 Consumer Key 和 Consumer Secret 都會產生全新的一組。若有需要,可請 integration 對方更新一下。但是對方也可以續用 Production 的 Connected App Key/Secret, Authorization 一樣打得通。 這邊所謂的打得通,有其侷限性。以get token來說,確實原本的 Production 的 Key 和 Secret 都還是可以讓 Sandbox 的 username 來使用,也可以得到一副 access_token。但如果拿這個 token 去在 Sandbox 做 Query,就會得到一個 [{"message":"This session is not valid for use with the REST API","errorCode":"INVALID_SESSION_ID"}] 的 error message。 要解決上述 invalid session id 的問題,可以在 Sandbox 幫此 user 開通  Use Any API Client 的權限 (在 Profile 或 Permission Set 開都可以) 或者是關掉MFA,可能也可以解決這個問題。(待驗證) 打 API 的時候,原則上要在 password 上 append Security Token。但如果來源是 Trust IP 的話,Security Token可免。要附上也可以,多附也不會出錯。 但是如果密碼是正確的、Security Token 是不正確的……一樣會被擋下來哦!