About this question
I'm trying to get the access token using Salesforce Username/Password OAuth flow. I have created a connected app, provided full access in the Oauth scopes and pre-authorized System Admin profile users. I'm sending a POST request in Salesforce and added all the query parameters client_id, client_secret, username, password, grant_type. I was expecting the response body to contain the access token but ended up getting html content. Am I doing something wrong somewhere? Why unable to get access to https www salesforce com login? I thought this OAuth flow is pretty straight forward.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" style="visibility: visible;" lang=en-us xml:lang=en-us> <head> <meta name="viewport" content="initial-scale=1.0"/> <meta name="description" content="Salesforce Customer Secure Login Page. Login to your Salesforce Customer Account." /> <title>Login | Salesforce</title> <meta name="format-detection" content="telephone=no" /> <link rel="stylesheet" type="text/css" href="/css/sfdc_210.css" /> <style type="text/css">html{visibility: hidden;}a{color:#0070d2;}body{background-color:#F4F6F9;}#content,.container{background-color:#ffffff;}#header{color:#16325c;}body{display: table; width:100%;}#content{margin-bottom:24px;}#wrap{height:100%;}</style> <style type="text/css"> html { visibility: hidden; } </style> [removed]if (self == top) {document.documentElement.style.visibility = 'visible';} else {[removed] = ''; top.location = self.location; setTimeout(function(){document.body[removed]='';}, 1);window.self.onload=function(evt){document.body[removed]='';};}[removed] [removed]var SFDCSessionVars={"server":"https://login.salesforce.com/login/sessionserver212.html","im":false,"ah":"active","save":"Save","saveOne":"Save 1 Change","sum":"#p# Saved Usernames","iaac":false,"hac":"Choose a Username","suo":"1 Saved Username","title":" | Salesforce","saveMany":"Save #p# Changes","lpt":"Login","lllbl":"Lightning Login","host":"login.salesforce.com","le":false,"heu":"Edit Username List","ic":false,"lh":false,"hidp":"Log In Using","ih":"inactive","dc":"Username removed. Click Save to Commit Changes."};[removed] [removed][removed] [removed][removed] [removed]LoginHint.hideLoginForm();[removed] <link rel="canonical" href="https://login.salesforce.com/?locale=us"/> <link rel="alternate" href="https://login.salesforce.com/?locale=nb-no" hreflang="nb-no"/> <link rel="alternate" href="https://login.salesforce.com/?locale=de" hreflang="de"/> <link rel="alternate" href="https://login.salesforce.com/?locale=tw" hreflang="zh-Hant-tw"/> <link rel="alternate" href="https://login.salesforce.com/?locale=ru" hreflang="ru"/> <link rel="alternate" href="https://login.salesforce.com/?locale=fi" hreflang="fi"/> <link rel="alternate" href="https://login.salesforce.com/?locale=jp" hreflang="ja-jp"/> <link rel="alternate" href="https://login.salesforce.com/?locale=fr" hreflang="fr"/> <link rel="alternate" href="https://login.salesforce.com/?locale=br" hreflang="pt-br"/> <link rel="alternate" href="https://login.salesforce.com/?locale=se" hreflang="sv"/> <link rel="alternate" href="https://login.salesforce.com/?locale=uk" hreflang="en-gb"/> <link rel="alternate" href="https://login.salesforce.com/?locale=ca" hreflang="en-ca"/> <link rel="alternate" href="https://login.salesforce.com" hreflang="en-us"/> <link rel="alternate" href="https://login.salesforce.com/?locale=in" hreflang="en-in"/> <link rel="alternate" href="https://login.salesforce.com/?locale=en-hk" hreflang="en-hk"/> <link rel="alternate" href="https://login.salesforce.com/?locale=kr" hreflang="ko-kr"/> <link rel="alternate" href="https://login.salesforce.com/?locale=cn" hreflang="zh-Hans-cn"/> <link rel="alternate" href="https://login.salesforce.com/?locale=mx" hreflang="es-mx"/> <link rel="alternate" href="https://login.salesforce.com/?locale=it" hreflang="it"/> <link rel="alternate" href="https://login.salesforce.com/?locale=fr-ca" hreflang="fr-ca"/> <link rel="alternate" href="https://login.salesforce.com/?locale=es" hreflang="es"/> <link rel="alternate" href="https://login.salesforce.com/?locale=ap" hreflang="en-sg"/> <link rel="alternate" href="https://login.salesforce.com/?locale=eu" hreflang="en"/> <link rel="alternate" href="https://login.salesforce.com/?locale=th" hreflang="th"/> <link rel="alternate" href="https://login.salesforce.com/?locale=au" hreflang="en-au"/> <link rel="alternate" href="https://login.salesforce.com/?locale=da-dk" hreflang="da-dk"/> <link rel="alternate" href="https://login.salesforce.com/?locale=nl" hreflang="nl"/> </head> <body onload="lazyload();">
<button class="button primary fiftyfifty right" id="hint_save_edit" name="Save" onclick="LoginHint.saveHintEdit();">Save</button> <button class="button secondary fiftyfifty" id="hint_back_edit" name="Cancel" onclick="LoginHint.showChooser();">Cancel</button> <form name="login" method="post" id="login_form" onsubmit="handleLogin();" action="https://login.salesforce.com/" target="_top" autocomplete="off" novalidate="novalidate"> <input type="hidden" id="pqs" name="pqs" value="?grant_type=password&client_id=3MVG9QBLg8QGkFerS4zTdoCnaDOPl5Qm6KEYMSYQT.eNLlQpt9ox.0fG6R8tHAESMKKBlbf2b4ql_hWZbskgu&client_secret=4869032460675835042&username=pkonda@cardlytics.com.dev&password=AppleJack_2019"/> <input class="input r4 wide mb16 mt8 password" type="password" id="password" name="pw" onkeypress="checkCaps(event)" autocomplete="off"/>
Caps Lock is on. <input class="button r4 wide primary" type="submit" id="Login" name="Login" value="Log In" /> <input type="checkbox" class="r4 fl mr8" style="" id="rememberUn" name="rememberUn">
</form> To go to your company's login page, enter the custom domain name.
<form onsubmit="DomainSwitcher.handleMyDomain();return false;"> <input type="text" class="input wide focus mt8 mb16" name="mydomain" id="mydomain" onkeyup="DomainSwitcher.updateMyDomain(this, event);"/> https:// domain.my.salesforce.com </form> <input type="hidden" id="mydomain_suffix" value=".my.salesforce.com"/> <input type="hidden" id="community_suffix" value=".ap3.force.com"/> <button class="button primary fiftyfifty right" id="mydomainContinue" name="Continue" onclick="DomainSwitcher.handleMyDomain();">Continue</button> <button class="button secondary fiftyfifty" id="hint_back_domain" onclick="DomainSwitcher.dismissCustomDomain('Login',' | Salesforce');">Back</button> Not a customer?
Try for Free <iframe frameborder="0" src="/s.gif" id="marketing" name="marketing" scrolling="no" title="Marketing" tabindex="-1"sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts" ></iframe> Login [removed]LoginHint.getSavedIdentities(false);[removed] [removed][removed] [removed][removed] [removed][removed] [removed][removed] [removed]function handleLogin(){document.login.un.value=document.login.username.value;document.login.width.value=screen.width;document.login.height.value=screen.height;}function lazyload(){document.getElementById("pwcapsicon").src="/img/icon/capslock_blue.png";document.getElementById("marketing").src="https://c.salesforce.com/login-messages/promos.html";}loader();[removed] </body> </html>