How to securely authenticate users with Twitter on xamarin mobile apps?

佐手、 提交于 2021-02-11 15:48:22

问题


I would like to get a user id and user access token from Twitter in a Xamarin app. I would prefer to use a library if possible like Xamarin.Auth.

There is a nice description here how to do it: https://mobileprogrammerblog.wordpress.com/2016/01/23/xamarin-android-twitter-authentication/

In short:

var auth = new XA.OAuth1Authenticator(
    consumerKey: "CONSUMER_KEY",
    consumerSecret: "CONSUMER_SECRET", // THIS IS THE PROBLEM
    requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
    authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
    accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
    callbackUrl: new Uri("http://mobile.twitter.com/"));

BUT! That is insecure because it requires the app-secret, or consumer secret (or call it anything) which should not be included in any app. Facebook, Google and Microsoft (among others) are able to provide an SDK which uses other methods to authenticate the apps, so the apps can authenticate the users without containing their app-secret in the code.

Once again: I want to get the authenticated user's ID and his/her access-token. How to do it with Twitter?

来源:https://stackoverflow.com/questions/65037403/how-to-securely-authenticate-users-with-twitter-on-xamarin-mobile-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!