How to get a demo account in sandbox
How to get a demo account in sandbox
01 Nov 2018, 03:43
I managed to create a CID in the sandbox but the trading sandbox sandbox2-ct.spotware.com seems not available. How can I create a demo account in the sandbox then?
Replies
PanagiotisCharalampous
01 Nov 2018, 10:03
Hi swain.sun,
Thank you for posting in our forum. For development purposes, I would suggest to use a demo account on production environments instead of the sandbox.
Best Regards,
Panagiotis
@PanagiotisCharalampous
swain.sun
01 Nov 2018, 10:37
RE: more question about OAuth
Thanks for your replay. I did apply an app without sandbox. Now I'm trying to get the access token. However, I failed in first step:
https://sandbox-connect.spotware.com/apps/auth? client_id={your Partner's Public Client ID}& redirect_uri={your Redirection URI}& scope=accounts
It didn't retured with the auth code but a html script, any idea what I did wrong?
Panagiotis Charalampous said:
Hi swain.sun,
Thank you for posting in our forum. For development purposes, I would suggest to use a demo account on production environments instead of the sandbox.
Best Regards,
Panagiotis
@swain.sun
PanagiotisCharalampous
01 Nov 2018, 10:50
Hi swain.sun,
To get an access token from production environments, you need to use https://connect.spotware.com/ and not https://sandbox-connect.spotware.com/
Best Regards,
Panagiotis
@PanagiotisCharalampous
swain.sun
01 Nov 2018, 10:53
RE:
I used the production URL instead of the sandbox one. It returned HTML script of playground.Hi swain.sun,
To get an access token from production environments, you need to use https://connect.spotware.com/ and not https://sandbox-connect.spotware.com/
Best Regards,
Panagiotis
@swain.sun
PanagiotisCharalampous
01 Nov 2018, 10:58
Hi swain.sun,
Maybe you would like to have a look at our sample, to see how the authenitcation process is implemented.
Best Regards,
Panagiotis
@PanagiotisCharalampous
swain.sun
01 Nov 2018, 12:01
RE:
I read the code a bit. Here's the one I don't understand. public static AccessToken GetAccessToken(string connectUrl, string code, string redirectUri, string clientID, string clientSecret) { var client = new RestClient(connectUrl); var request = new RestRequest(@"apps/token?grant_type=authorization_code&code=" + code + "&redirect_uri=" + redirectUri + "&client_id=" + clientID + "&client_secret=" + clientSecret); var tokenResponse = client.ExecuteHi swain.sun,
Maybe you would like to have a look at our sample, to see how the authenitcation process is implemented.
Best Regards,
Panagiotis
@swain.sun
PanagiotisCharalampous
01 Nov 2018, 12:07
Ηι swain.sun,
I am not sure what the problem is. The function you posted performs a REST request and the token is returned in JSON format. Did you try to run the code?
Best Regards,
Panagiotis
@PanagiotisCharalampous
swain.sun
01 Nov 2018, 12:09
RE:
Sorry about the bad format when I was typing on phone. There should be a http get before this one to Ge the code, where I can't but only got a script. How can I get the code needed for token then?
public static AccessToken GetAccessToken(string connectUrl, string code, string redirectUri, string clientID, string clientSecret)
{
var client = new RestClient(connectUrl);
var request = new RestRequest(@"apps/token?grant_type=authorization_code&code=" + code + "&redirect_uri=" + redirectUri +
"&client_id=" + clientID + "&client_secret=" + clientSecret);
var tokenResponse = client.Execute<AccessToken>(request);
return JsonConvert.DeserializeObject<AccessToken>(tokenResponse.Content);
}
Panagiotis Charalampous said:
Hi swain.sun,
Maybe you would like to have a look at our sample, to see how the authenitcation process is implemented.
Best Regards,
Panagiotis
@swain.sun
swain.sun
01 Nov 2018, 12:13
RE:
My question is where to get the input parameter 'code'.
According to the doc, the code can be obtain by sending the request
https://sandbox-connect.spotware.com/apps/auth? client_id={your Partner's Id here}& redirect_uri={redirect_uri}& scope=accounts
Then the code can be used in the function above to get access token. However, when I send the reuqest, I didn't get the code but a html script.
Panagiotis Charalampous said:
Ηι swain.sun,
I am not sure what the problem is. The function you posted performs a REST request and the token is returned in JSON format. Did you try to run the code?
Best Regards,
Panagiotis
@swain.sun
swain.sun
01 Nov 2018, 12:15
RE:
My question is how to get the input parameter 'code' required by the function. According to the doc, by sending the request as below we can get the 'code', which I did but only get a html script.
https://sandbox-connect.spotware.com/apps/auth? client_id={your Partner's Id here}& redirect_uri={redirect_uri}& scope=accounts
Panagiotis Charalampous said:
Ηι swain.sun,
I am not sure what the problem is. The function you posted performs a REST request and the token is returned in JSON format. Did you try to run the code?
Best Regards,
Panagiotis
@swain.sun
PanagiotisCharalampous
01 Nov 2018, 12:20
Hi swain.sun,
The process goes as follows.
1) Redirect your application to connect site using your credentials
Response.Redirect(_connectUrl + "apps/auth?&client_id=" + _clientId + "&redirect_uri=" + HttpContext.Current.Request.Url.AbsoluteUri + "&customvariable=test&scope=trading");
2) The user will authenticate and then the Connect site with redirect back to your application with a Code in the query string. Read the Code
var code = HttpContext.Current.Request.QueryString["code"];
3) Now that you have the code, you can get the token
var token = AccessToken.GetAccessToken(_connectUrl, code, redirectUri, _clientId, _clientSecret);
Let me know if this helps.
Best Regards,
Panagiotis
@PanagiotisCharalampous
swain.sun
01 Nov 2018, 12:26
RE:
Thanks. That clarified a lot. Just wondering the string
&customvariable=test
is absolutely neccessary or optional?
And the request for code doesn't return json but html, we'll have to look for the "code" with the text?
Panagiotis Charalampous said:
Hi swain.sun,
The process goes as follows.
1) Redirect your application to connect site using your credentials
Response.Redirect(_connectUrl + "apps/auth?&client_id=" + _clientId + "&redirect_uri=" + HttpContext.Current.Request.Url.AbsoluteUri + "&customvariable=test&scope=trading");2) The user will authenticate and then the Connect site with redirect back to your application with a Code in the query string. Read the Code
var code = HttpContext.Current.Request.QueryString["code"];3) Now that you have the code, you can get the token
var token = AccessToken.GetAccessToken(_connectUrl, code, redirectUri, _clientId, _clientSecret);Let me know if this helps.
Best Regards,
Panagiotis
@swain.sun
PanagiotisCharalampous
01 Nov 2018, 12:37
&customvariable=test
No it is just an example
And the request for code doesn't return json but html, we'll have to look for the "code" with the text?
The request for code does not return something. It redirects to Connect site where authentication takes place. After the user authenticates, he is redirected back to your application. The code is in the query string of the redirect request.
Best Regards,
Panagiotis
@PanagiotisCharalampous
swain.sun
01 Nov 2018, 12:53
RE:
OK...it makes a lot sense now. I'll try it out. Thanks a lot for your help. :)
Panagiotis Charalampous said:
&customvariable=test
No it is just an example
And the request for code doesn't return json but html, we'll have to look for the "code" with the text?
The request for code does not return something. It redirects to Connect site where authentication takes place. After the user authenticates, he is redirected back to your application. The code is in the query string of the redirect request.
Best Regards,
Panagiotis
@swain.sun
... Deleted by UFO ...