Instagram API;
https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code
我的代码o
public void Login()
{
auth = new OAuth2Authenticator (
clientId: "3b5a1...be2f5",
scope: "basic+public_content+follower_list+comments+relationships+likes",
authorizeUrl: new Uri ("https://api.instagram.com/oauth/authorize/"),
redirectUrl: new Uri ("https://Instagramcallback.com/callback")
);
auth.Completed+= (sender, e) => {
//DismissViewController(true,null);
if(e.IsAuthenticated)
{
OAuth2Request request= new OAuth2Request("POST", new Uri("https://api.instagram.com/oauth/access_token"),null);
Account loggedInAccount=e.Account;
//save the account data for a later session
AccountStore.Create(this).Save(loggedInAccount,"Instagram");
// Take access_token out
}
else
{
// errors be showing at here
}
};
StartActivity (auth.GetUI (this));
-e.IsAuthenticated它将是假的.->无效的范围字段
OAuth 2.0身份验证,因此我们创建了OAuth2Authenticator。验证者负责管理用户界面并与身份验证服务进行通信。
Authenticators采用各种参数;在这种情况下,需要应用程序的ID,授权范围和Facebook的各种服务位置。
答案 0 :(得分:0)
来自Instagram doc:
要一次请求多个范围,只需将范围分隔为a 空间。在url中,这相当于一个转义空格(“+”)。
因此,您应该使用SPACES而不是“+”来分隔范围授权,因为xamarin auth已经对您的范围进行了编码。
...
scope: "basic public_content follower_list comments relationships likes",
...
+1如果有帮助ty!