public void generate_signature_when_token_is_url_encoded() { var context = new OAuthContext { RequestMethod = "GET", RawUri = new Uri("https://www.google.com/m8/feeds/contacts/default/base"), Token = "1/2", ConsumerKey = "context", SignatureMethod = SignatureMethod.RsaSha1 }; Assert.Equal( "GET&https%3A%2F%2Fwww.google.com%2Fm8%2Ffeeds%2Fcontacts%2Fdefault%2Fbase&oauth_consumer_key%3Dcontext%26oauth_signature_method%3DRSA-SHA1%26oauth_token%3D1%252F2", context.GenerateSignatureBase()); Assert.Equal( "https://www.google.com/m8/feeds/contacts/default/base?oauth_token=1%2F2&oauth_consumer_key=context&oauth_signature_method=RSA-SHA1", context.GenerateUrl()); }
private string CreateApiResourceRequest(IOAuthConsumer consumer, string relativePath) { // to request a protected resource via GET we: // 1. Construct the uri we want to access // 2. create an "OAuthContext" representing the request. // 3. Sign the context using our OAuth consumer implementation (calculates and sets the signature etc.) // 4. Generate a Uri from the OAuthContext context and return it. var absoloutePath = new Uri(Request.Uri, relativePath); var factory = new OAuthContextFactory(); OAuthContext context = factory.FromUri("GET", absoloutePath); consumer.SignContext(context, _testAccessToekn); return(context.GenerateUrl()); }