I am working on using the .NET SDK to obtain an oauth token. I am not sure what to do for the “AccessToken” value, since I do not have one yet?
var client = new SquareClient.Builder()
.Environment(Square.Environment.Production)
.AccessToken(access_token)
.Build();
Please advise on what to do? Thanks!
What version are you looking at? That was there previously for refreshing a token but isn’t required. For example:
var body = new ObtainTokenRequest.Builder(
"APPLICATION_ID",
"APPLICATION_SECRET",
"authorization_code")
.Code("CODE_FROM_AUTHORIZE")
.Build();
try
{
ObtainTokenResponse result = await oAuthApi.ObtainTokenAsync(body);
}
catch (ApiException e){};
Bryan-Square:
var body = new ObtainTokenRequest.Builder(
"APPLICATION_ID",
"APPLICATION_SECRET",
"authorization_code")
.Code("CODE_FROM_AUTHORIZE")
.Build();
try
{
ObtainTokenResponse result = await oAuthApi.ObtainTokenAsync(body);
}
catch (ApiException e){};
My question is more how do I instantiate oAuthApi? I am use to doing the following
var client = new SquareClient.Builder()
.Environment(Square.Environment.Production)
.AccessToken(access_token)
.Build();
IOAuthApi oAuthApi = client.OAuthApi;
but if I dont have an access token, what do I do?
Oh sorry, I miss read. You won’t need to set the AccessToken
. Since the body has the client_secret
and client_id
we will know what application the request is for.