I have finally jumped through all the hoops and I’m ready to make a call to the Square API to obtain the coveted access_token.
ObtainTokenRequest TokenReq = new ObtainTokenRequest.Builder(ApplicationId, Secret, "authorization_code")
.Code(Code)
.Build();
try
{
ObtainTokenResponse TokenResp = SquareApi.OAuthApi.ObtainToken(TokenReq);
}
catch (ApiException Ex)
{
string Errors = string.Empty;
foreach (Error Err in Ex.Errors)
{
Errors += string.Format("{0} - {1}: {2}{3}. ",
Err.Category,
Err.Code,
Err.Detail,
(Err.Field != null && Err.Field.Length > 0 ? string.Format(" ({0})", Err.Field) : string.Empty));
}
Response.Write(Errors);
}
This is throwing an ApiException of V1_ERROR - service.not_authorized: Not Authorized., I’m not really sure what to do with it, what is it telling me? I’ve double checked the values of my sandbox access tokey, application id and secret.
Thanks,
Russ