我有具有以下POST
方法現有的C#項目:C#OAuthWebSecurity Google提供商網址?
// POST: /Account/ExternalLogin
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult ExternalLogin(string provider, string returnUrl)
{
return new ExternalLoginResult(provider, Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));
}
其中採用:
OAuthWebSecurity.Login(provider, ...);
我有點新到OAuth,並沒有做任何事的中這個C#項目。我不但是實現上的Android應用程序谷歌的授權,我想用下面的類/方法的HttpPost:
public class TaskPostAPI extends AsyncTask<String, Void, String>
{
GoogleApiClient googleAPI;
public TaskPostAPI(GoogleApiClient googleAPI){
this.googleAPI = googleAPI;
}
@Override
protected String doInBackground(String... urls){
String response = "";
for(String url : urls){
DefaultHttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(url);
try{
List<NameValuePair> nvPairs = new ArrayList<NameValuePair>(2); //(3);
//nvPairs.add(new BasicNameValuePair("personName", Plus.PeopleApi.getCurrentPerson(googleAPI).getDisplayName()));
//nvPairs.add(new BasicNameValuePair("personGooglePlusProfile", Plus.PeopleApi.getCurrentPerson(googleAPI).getUrl()));
//nvPairs.add(new BasicNameValuePair("personEmail", Plus.AccountApi.getAccountName(googleAPI)));
nvPairs.add(new BasicNameValuePair("provider", ???));
URL u = new URL(url);
nvPairs.add(new BasicNameValuePair("returnUrl", u.getProtocol() + "://" + u.getHost()));
post.setEntity(new UrlEncodedFormEntity(nvPairs));
HttpResponse execute = client.execute(post);
InputStream content = execute.getEntity().getContent();
BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
String s = "";
while((s = buffer.readLine()) != null)
response += s;
}
catch(Exception ex){
ex.printStackTrace();
}
}
return response;
}
}
所以我的問題:我應該把在POST-method's
???。那麼什麼是Provider
?在我的Android應用程序中,我使用Google
登錄,並獲得GoogleApiClient
和Person
(com.google.android.gms.plus.model.people.Person
)。
在this website我看到以下網址:https://accounts.google.com/o/oauth2/auth
。這是我應該使用的網址爲provider
?或者我應該將parameters
添加到此網址?或者我應該使用完全不同的字符串作爲provider
?
PS:如果有人可以給我一個鏈接到的provider-urls
列表(如Google's
,Facebook's
,Twitter's
等),以及如何使用它們的C#OAuthWebSecurity
我將不勝感激。
在此先感謝您的回覆。