I followed this link
http://samjarawan.blogspot.co.uk/2010/09/building-real-windows-phone-7-twitter_18.html
step by step and when I am running my app, I am getting an error i.e. "Error Calling Twitter".
When I searched about it, I found that in this part of code
var client = new RestClient
{
Authority = "https://api.twitter.com/oauth",
Credentials = credentials,
HasElevatedPermissions = true,
SilverlightAcceptEncodingHeader = "gzip",
DecompressionMethods = DecompressionMethods.GZip
};
I need to do some changes, but what changes didn't find any where. Another answer I got that I need to update Hammock and Tweetsharp, but its already updated. Please suggest me and help me out.
Try changing DecompressionMethods or SilverlightAcceptEncodingHeader.
Related
I want to download release asset zipball´s in a C# application for further use.
I´m using Octokit to get all release informations from the repo, including the respective browserdownload_url.
After some research it seemed to me, that you cant download this release asset zip´s via octokit, so trying with httpclient as suggested by some SO posts, that were asking these questions.
The release zip´s are on a Github Enterprise Repository, so they require Authentication.
And that is probably my issue, i cant make the authentication work with the httpClient...
The request always responds with Code 404
(which is the regular behaviour if you try by putting the url into the regular browser without logging in)
My actual implementation looks like this
public void DownloadRelease(string dlUrl, string targetPath)
{
var githubToken = "aaaaaaaaaaabbbbbbbbbcccccccccdddddddddd"; //Token created in the github developer settings with all available rights
//dlUrl = https://github.server.de/organization/project/releases/download/v1.2.34/release.zip
using (var client = new System.Net.Http.HttpClient())
{
var credentials = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}:", githubToken);
credentials = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(credentials));
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials);
//client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", githubToken);
var contents = client.GetByteArrayAsync(dlUrl).Result;
System.IO.File.WriteAllBytes(targetPath, contents);
}
}
Update:
At the End we followed the way of using the curl way:
https://docs.github.com/en/enterprise-server#3.0/rest/reference/repos#download-a-repository-archive-zip
And one more mistake on my end: There were releases without downloadable Asset IDs which i didnt catch in the code.
Based on the documentation (https://docs.github.com/en/enterprise-server#2.22/rest/overview/other-authentication-methods#via-oauth-and-personal-access-tokens) my best guess is, that your crendentials are wrong.
The docs say, the format should be username:token, yet you are only using token followed by a colon : - that doesn't look right to me, either.
So essentially you need to refactor your credentials variable a bit:
var credentials = $"{username}:{githubToken}";
I am new to xamarin android. I am trying to implement OAuth in xamarin android with Google as Identity provider. I have registered my app with google and got the client id and Client secret which I am using when user click on login button as below.
void OnLoginClicked(object sender, EventArgs e)
{
var authenticator = new OAuth2Authenticator(
Constants.ClientId,
Constants.ClientSecret,
Constants.Scope,
new Uri(Constants.AuthorizeUrl),
new Uri(Constants.RedirectUrl),
new Uri(Constants.AccessTokenUrl));
authenticator.Completed += OnAuthCompleted;
authenticator.Error += OnAuthError;
var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(authenticator);
}
It redirects to google but gives 403 error as 'disallowed_useragent'.
According to this, google "no longer allow OAuth requests to Google in embedded browsers known as web-views"
After going through some forums and stackoverflow questions, I come to know that
chromecustomtabs need to be use.
So here I have two questions
Is there alternate solution to chromecustomtabs?
If above answer is no, then if I understand correctly then I need to add below code in my project. My question is what modification needs to be done in OnLoginClicked function? Does the OAuth2Authenticator required in that case?
My code:
var mgr = new CustomTabsActivityManager (this);
mgr.CustomTabsServiceConnected += delegate {
mgr.LaunchUrl ("http://xamarin.com");
};
mgr.BindService ();
Any suggestions/links would be appreciated. Thanks.
Please read this topic. Xamarin Auth 1.5.0 supported CustomTabsIntent.
This is an answer to your section question:
There is a parameter on OAuth2Authenticator called isUsingNativeUI. You must set it to true. This will cause Xamarin.Auth to use the CustomTabs service inside Android rather than the webview.
Your code becomes:
var authenticator = new OAuth2Authenticator(
Constants.ClientId,
Constants.ClientSecret,
Constants.Scope,
new Uri(Constants.AuthorizeUrl),
new Uri(Constants.RedirectUrl),
new Uri(Constants.AccessTokenUrl),
null,
true); // <-- This is it isUsingNativeUI
I wish it were the default.
I was working on this program that connects my users through their Facebook accounts. It's been working quiet stable for the past couple of weeks, and I was able to add more value to my program during that period. However, starting today I was unable to connect through Facebook as I usually do. Whenever I ask for App authorization (1st step) I get a "Given URL is not permitted by the Application configuration" error, Even tho i didn't change anything in my App Settings.
I looked everywhere to check if maybe Facebook did some Updates or something, but couldn't find anything. Last time i logged in successfully was the 30th of March.
How could have this happened if I didn't edit any of my code, and apparently Facebook didn't either! Any help would be greatly appreciated :)
private string GenerateLoginUrlFacebook()
{
dynamic parameters = new ExpandoObject();
parameters.client_id = Globals.FBapplicationID;
parameters.redirect_uri = "https://www.facebook.com/connect/login_success.html";
parameters.response_type = "token";
parameters.display = "popup";
if (!string.IsNullOrWhiteSpace(Globals.FBextendedPermissionsNeeded))
parameters.scope = Globals.FBextendedPermissionsNeeded;
var fb = new FacebookClient();
Uri loginUri = fb.GetLoginUrl(parameters);
return loginUri.AbsoluteUri;
}
private void googleplue()
{
Moment body = new Moment();
ItemScope itemScope = new ItemScope();
itemScope.Id = "replacewithuniqueforaddtarget";
itemScope.Image = "http://www.google.com/s2/static/images/GoogleyEyes.png";
itemScope.Type = "";
itemScope.Description = "The description for the action";
itemScope.Name = "An example of add activity";
body.Object = itemScope;
body.Type = "http://schema.org/AddAction";
MomentsResource.InsertRequest insert =
new MomentsResource.InsertRequest(
plusService,
body,
userId,
MomentsResource.Collection.Vault);
// Moment wrote = insert.Fetch();
}
I tried this but not work please give me any other solution.
Moment isn't the same as posting to Google+ timeline its not possible to post to the Google+ timeline. see Issue 41: Write access to the streams
In order to post moments which isn't the same thing, you need to be able to set request_visible_actions as part of the authentication process and it doesn't appear that its possible to do with with the current version of the C# client library see
If you want to post moments and not write to a user time line then your going to have to figure out how to send the request_visible_actions as part of your authentication. if you do figure out how to do that please post the answer on my question.
I am using LinqToTwitter in my C# desktop application. Trying to send tweets and tweets with image to Twitter using OAuth credentials. Initially I am using these required attributes of my own Twitter application:
var auth = new SingleUserAuthorizer
{
Credentials = new SingleUserInMemoryCredentials
{
ConsumerKey = "key",
ConsumerSecret = "secret",
TwitterAccessToken = "token",
TwitterAccessTokenSecret = "tokensecret"
}
};
var context = new TwitterContext(auth);
context.UpdateStatus("Hello World");
NOTE: I have double checked that I am using correct values for above keys and tokens, but its always erroring 401 Unauthorized.
NOTE: Also I have checked this link for any mistake: http://linqtotwitter.codeplex.com/wikipage?title=LINQ%20to%20Twitter%20FAQ&referringTitle=Documentation
Any help to resolve this ?
Your code seems to be fine.
The FAQ, which you reference, is the best resource right now.
What type of application are you building, e.g. ASP.NET, Windows Phone, etc.?
You might also try downloading the source code and checking to see if the LinqToTwitterDemos project will work for you.