格式错误的访问令牌190错误 [英] Malformed access token 190 error

查看:116
本文介绍了格式错误的访问令牌190错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当尝试重定向以获取新的访问令牌时出现错误:

 (OAuthException  - #190)格式错误的访问令牌AQClEC8NbS1tbO4_HzqqZwVy2Inrk5I7vBpszPDPN0dVOV0ekurwNEpqzlWe2hQzl2KNZ5BwiSvL16bDPhR5IxFeJXEXBdM67uky7iwKbYKIVoRF__iyayyXBgcIp939gEZNtCUxyO4ZKZHQ9xmEwDstaOgq_bAvtygwv3YUeEYD9wftsytMZYwVxDO7rjq-2I3-XCYj643-6_1yKZ0dDahAB00iBqJqw1xiZ-l1​​kzStmA_pwMwO5dtBHZozp-L2hp0JEeTL0Fhc5CG1zbJ8Om6kyKBWyZuc0AtOrdSjgcBQBv9hQSF5pwsMZvFDGcjiwSc 

什么可能可能是我做的问题这种重定向方法:

  string redirecturl = @https://graph.facebook.com/oauth/authorize?client_id= 507061112747022&安培; REDIRECT_URI = HTTP://本地主机:63695 / FacebookChatApi / Default.aspx的; 
Response.Redirect(redirecturl);

我正在阅读访问令牌如下:

  string accessToken = Request [code]; 
var client = new FacebookClient(accessToken); //这里是发生错误的地方




  1. 这是否是正确的方法获取客户端访问令牌?

  2. 为什么在阅读代码

  3. 令牌不是一个令牌,而是一个网址改为: https://developers.facebook.com/tools/debug/ ?OG /目标q = AQClEC8NbS1tbO4_HzqqZwVy2Inrk5I7vBpszPDPN0dVOV0ekurwNEpqzlWe2hQzl2KNZ5BwiSvL16bDPhR5IxFeJXEXBdM67uky7iwKbYKIVoRF__iyayyXBgcIp939gEZNtCUxyO4ZKZHQ9xmEwDstaOgq_bAvtygwv3YUeEYD9wftsytMZYwVxDO7rjq



    我不知道你得到它谁,为什么你得到它,而不是访问令牌 - 你没有显示足够的代码。从我看到的,我相信你不正确地生成你的 redirecturl 。以下是我的一个项目中的一段代码 - 请尝试一下,如果它适用于您:

      / 1.将用户重定向到登录页面:
    var redirectUri =http:// localhost:63695 / FacebookChatApi / Default.aspx;

    var service = new FacebookClient();
    var loginUrl = service.GetLoginUrl(new {
    client_id = ConfigurationProvider.FacebookAppId,
    client_secret = ConfigurationProvider.FacebookAppSecret,
    redirect_uri = redirectUri,
    response_type =code ,
    scope =manage_pages,publish_actions,user_photos,publish_stream//根据需要添加其他权限
    });

    Response.Redirect(loginUrl);

    // 2.当用户授权时,获取访问令牌
    //注意:代码在FacebookChatApi / Default.aspx页面上执行
    var redirectUri =http://本地主机:63695 / FacebookChatApi / Default.aspx的; //必须和登录电话一样!
    var fb = new FacebookClient();
    dynamic result = fb.Post(oauth / access_token,new
    {
    client_id = ConfigurationProvider.FacebookAppId,
    client_secret = ConfigurationProvider.FacebookAppSecret,
    redirect_uri = redirectUri ,
    code = code
    });

    var accessToken = result.access_token;


    when trying to redirect to gain a new access token an error occurred saying :

    (OAuthException - #190) Malformed access token AQClEC8NbS1tbO4_HzqqZwVy2Inrk5I7vBpszPDPN0dVOV0ekurwNEpqzlWe2hQzl2KNZ5BwiSvL16bDPhR5IxFeJXEXBdM67uky7iwKbYKIVoRF__iyayyXBgcIp939gEZNtCUxyO4ZKZHQ9xmEwDstaOgq_bAvtygwv3YUeEYD9wftsytMZYwVxDO7rjq-2i3-XCYj643-6_1yKZ0dDahAB00iBqJqw1xiZ-l1kzStmA_pwMwO5dtBHZozp-L2hp0JEeTL0Fhc5CG1zbJ8Om6kyKBWyZuc0AtOrdSjgcBQBv9hQSF5pwsMZvFDGcjiwSc
    

    what possibly could be the problem i am doing this method to redirect :

    string redirecturl = @"https://graph.facebook.com/oauth/authorize?client_id=507061112747022&redirect_uri=http://localhost:63695/FacebookChatApi/Default.aspx";
        Response.Redirect(redirecturl);
    

    and i am reading the access token as follow :

    string accessToken=Request["code"];
    var client = new FacebookClient(accessToken); // here is where the error occurred 
    

    1. Is this the right method to get a client access token ?
    2. why this error is occurring when reading the code value

    解决方案

    according to Facebook Debug tool, your token is not a Token but a URL instead: https://developers.facebook.com/tools/debug/og/object?q=AQClEC8NbS1tbO4_HzqqZwVy2Inrk5I7vBpszPDPN0dVOV0ekurwNEpqzlWe2hQzl2KNZ5BwiSvL16bDPhR5IxFeJXEXBdM67uky7iwKbYKIVoRF__iyayyXBgcIp939gEZNtCUxyO4ZKZHQ9xmEwDstaOgq_bAvtygwv3YUeEYD9wftsytMZYwVxDO7rjq

    I'm not sure who you get it, and why you get it instead of access token - you did not show enough code. From what I saw, I believe you generate your redirecturl incorrectly. Below is a piece of code from one of my project - please try it and let me know if it works for you:

    // 1. redirect user to the login page:
    var redirectUri = "http://localhost:63695/FacebookChatApi/Default.aspx";
    
    var service = new FacebookClient();
    var loginUrl = service.GetLoginUrl(new {
        client_id = ConfigurationProvider.FacebookAppId,
        client_secret = ConfigurationProvider.FacebookAppSecret,
        redirect_uri = redirectUri,
        response_type = "code",
        scope = "manage_pages, publish_actions, user_photos, publish_stream" // Add other permissions as needed
    });
    
    Response.Redirect(loginUrl);
    
    // 2. And when user authorizes, get the access token
    // NOTE: code executes on FacebookChatApi/Default.aspx page
    var redirectUri = "http://localhost:63695/FacebookChatApi/Default.aspx";  // must be the same as in the login call!
    var fb = new FacebookClient();
    dynamic result = fb.Post("oauth/access_token", new
    {
        client_id = ConfigurationProvider.FacebookAppId,
        client_secret = ConfigurationProvider.FacebookAppSecret,
        redirect_uri = redirectUri,
        code = code
    });
    
    var accessToken = result.access_token;
    

    这篇关于格式错误的访问令牌190错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆