Reputation: 47
It's my first experience to code for wp7, and I have some trouble with it. When I state token_req = "http://api.server.com/oauth/token" it's ok, but when I state *https ,it can't connect, so I get "The remote server returned an error: NotFound." mistake at line
WebResponse response = (HttpWebResponse)request.EndGetResponse(result);
const string results
private void button1_Click(object sender, RoutedEventArgs e)
{
string token_req = "https://api.server.com/oauth/token";
string client_id = "...";
string client_secret = "...";
string username = Field_Login.Text;
string password = Field_Password.Password;
string token_req_param = "grant_type=password&client_id=" + client_id + "&client_secret=" + client_secret + "&username=" + username + "&password=" + password;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(token_req+"?"+token_req_param);
request.BeginGetResponse(GetCallback, request);
}
void GetCallback(IAsyncResult result)
{
WebRequest request = (HttpWebRequest)result.AsyncState;
WebResponse response = (HttpWebResponse)request.EndGetResponse(result);
using (StreamReader httpwebStreamReader = new StreamReader(response.GetResponseStream()))
{
results = httpwebStreamReader.ReadToEnd();
}
response.Close();
}
In addition I can't connect to this url with IE, which I have with wp7 emulator. =\
Upvotes: 1
Views: 578
Reputation: 672
Error Not Found is a generic WCF Error message, your best bet is to use Fiddler although from my experience you havent set up HTTPS to work on your service, if you want to setup HTTPS connections you will need more magic, which you can get from
https://github.com/geersch/WcfOverHttps
Upvotes: 1
Reputation: 2891
Are you trying to use a self-signed cert?
If so, then you must install the cert on the phone which can only be done by pointing the WebBrowserTask to a remote url of the cert. It sucks but this is the only way.
Upvotes: 1