开发者

RPX API Call auth_info is returning "missing parameter" error

I cannot get the RPX auth_info API call to work. It keeps returning the error: "Missing parameter: apiKey" I am using the C# RPX Helper Class provided on their Wiki:RPX Helper Class

Below is my code in my Page_Load method. The RPX service works by sending a POST to a Url that I specify. My code gets the token from the post data shown below. Then I call the A开发者_如何学PythonuthInfo API method.

string token = Request.Params["token"];
string apiKey = "xxxxxxxxxxxxxxx"; //my API key
Rpx rpx = new Rpx(apiKey, "http://rpxnow.com");
XmlElement xmlElement = rpx.AuthInfo(token);

Everything looks good. The token is populated. Within their code, the "apiKey" value pair is added to the post data written to the Request stream. Has anyone had luck with this? Any ideas why this is not working? Thanks.


Found the answer for anyone else looking. Example code is rubbish.

You need to set the base url to https://rpxnow.com - provided code is wrong. I can post the provided url, but it must be over HTTPS and not HTTP


The RPX sample code isn't very clear. I was getting a 404 error when the ApiCall method was being called.

Javascript:

janrain.settings.tokenUrl = 'http://mydomain/Test.ashx';

Test.ashx

    public void ProcessRequest(HttpContext context) {

        using (StreamWriter writer = new StreamWriter(context.Server.MapPath("/test.txt"))) {
            var token = context.Request.Form["token"];
            writer.WriteLine("Token: " + token);

            try {
                var rpx = new Rpx("my_id", "https://rpxnow.com/");
                var authInfo = rpx.AuthInfo(token);
                var doc = XDocument.Load(new XmlNodeReader(authInfo));
                writer.WriteLine(doc.Root.Descendants("displayName").First().Value);
                writer.WriteLine(doc.Root.Descendants("identifier").First().Value);
            }
            catch (Exception ex) {
                writer.WriteLine("Error: " + ex.Message);
            }

            foreach (string header in context.Request.Headers)
                writer.WriteLine(header + " - " + context.Request.Headers[header]);
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜