I’ve looked at the Build With OAuth page https://developer.squareup.com/docs/oauth-api/build-with-oauth and I see the variables with the url data
_SQ_SANDBOX_DOMAIN
_SQ_DOMAIN
_SQ_AUTHZ_URL
But I don’t see documented any where what the actual values are. How do I create the link for a user to grant my application authorization to do payment transactions on their behalf?
I’m using .Net, is the url info in the SDK, if so where would I find it?
Thanks
sjosey
April 30, 2020, 4:43pm
2
Hi @RussPete , in Step 2.1 it references a PHP template file which has these values.
To reference here:
_SQ_SANDBOX_DOMAIN
= “connect.squareupsandbox.com ”
_SQ_DOMAIN
= “connect.squareup.com ”
_SQ_AUTHZ_URL
= “/oauth2/authorize”
Gary
January 21, 2021, 4:03am
3
I know this reply may be late. Below is the code I use to generate the URL in C#. More information can be found here .
Implementation :
/// <summary>
/// Builds a URL for authorizing application
/// </summary>
/// <remarks><a href="https://developer.squareup.com/docs/oauth-api/how-oauth-works"/></remarks>
/// <param name="squareEnvironment">environment</param>
/// <param name="squareApplicationId">client_id</param>
/// <param name="scope">permissions</param>
/// <returns>URL to authorize application access to merchant </returns>
string AuthorizationUrl(string squareEnvironment, string squareApplicationId, string scope)
{
string authorizationBaseUrl = squareEnvironment == "Production" ?
"https://connect.squareup.com/" : "https://connect.squareupsandbox.com/";
var sb = new StringBuilder();
sb.Append(authorizationBaseUrl);
sb.Append("oauth2/authorize?client_id=");
sb.Append(squareApplicationId);
sb.Append("&scope=");
sb.Append(scope);
string url = sb.ToString();
return url;
}
Usage :
string url = AuthorizationUrl(
_config["SquareEnvironment"],
_config["SquareApplicationId"],
"MERCHANT_PROFILE_READ+ORDERS_WRITE+PAYMENTS_WRITE");
Last thing - this question should be tagged with NET as well.