首页 \ 问答 \ django-social-auth的OAuthException异常(OAuthException exception with django-social-auth)

django-social-auth的OAuthException异常(OAuthException exception with django-social-auth)

我正在使用django-social-auth来验证用户为我的网站登录facebook。

<a href="{% url socialauth_begin 'facebook' %}?redirect_uri={{SITE_URL}}complete/facebook/">

这正确地引导我进入auth对话框,但是当我在对话框中单击“Go To App”时,我从社交身份验证中收到此错误:

Request Method: GET
Request URL:    http://[site_url]/complete/facebook/?state=DHlD9efEDau286xRGn2HtVpZ9AbooD3y&code=AQCACZRE3WYGMyBSII1eD-H8Sl8yDUtL6VoZ4qJPKSQ_NDBAoE_6JE7-4Ef353utpAygCZVJMUKiLNs_evC-y2oezOKRsH_njtFZW4FwPE2XoaFm14sdbtUkj1QsqivY6DSpGpsmTNCCs3twYxx-6_C-e1OWEcnd4x6SoBg59LmCUsWhocu739h_ppdLRR_wPjY
Django Version: 1.3.1
Exception Type: AuthFailed
Exception Value:    
Authentication failed: There was an error authenticating the app
Exception Location: /app/.heroku/src/social-auth/social_auth/backends/facebook.py in auth_complete, line 131Request Method: GET
Request URL:    http://[site_url]/complete/facebook/?state=DHlD9efEDau286xRGn2HtVpZ9AbooD3y&code=AQCACZRE3WYGMyBSII1eD-H8Sl8yDUtL6VoZ4qJPKSQ_NDBAoE_6JE7-4Ef353utpAygCZVJMUKiLNs_evC-y2oezOKRsH_njtFZW4FwPE2XoaFm14sdbtUkj1QsqivY6DSpGpsmTNCCs3twYxx-6_C-e1OWEcnd4x6SoBg59LmCUsWhocu739h_ppdLRR_wPjY

我的需求文件指向django-social-auth的分叉版本,所以我可以在错误周围放置一些打印语句。 拨打电话后似乎发生了故障

https://graph.facebook.com/oauth/access_token?code=AQCc6tIfxJTQN64GGQsDVbT4BCK1hYGypw2oMFQjjMQf-kfJqrWtI-vGe78fJJJHTL6w5yuau90vQu8msVGDpZh30HgUYkwdXhAKJcC9MCf8h6bp1e23wxkkMzP5eaT2j7xOCorn-KgeRv-ZJA40U87GDx1_592amAlSemS4zhXaoAv7JWRHl9NzBFtJ6cuGdbg&client_secret=[app_secret]&redirect_uri=http%3A%2F%2F[site_url]%2Fcomplete%2Ffacebook%2F%3Fredirect_state%3DDHlD9efEDau286xRGn2HtVpZ9AbooD3y&client_id=[app_id]

我从中获得的错误是

{
      "error": {
      "message": "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request",
      "type": "OAuthException",
      "code": 100
   }
}

但是,如果我在URL的末尾添加斜杠,我会收到此错误:

{
   "error": {
     "message": "Error validating application. Invalid application ID.",
     "type": "OAuthException",
     "code": 101
  }
}

我向你保证app_id是正确的

我知道这是一个很长的阅读,但有没有人有任何关于如何解决这个问题的建议?


I'm using django-social-auth to authenticate users for facebook login for my website.

<a href="{% url socialauth_begin 'facebook' %}?redirect_uri={{SITE_URL}}complete/facebook/">

This correctly leads me to an auth dialog, but then when I click "Go To App" in the dialog I get this error from social auth:

Request Method: GET
Request URL:    http://[site_url]/complete/facebook/?state=DHlD9efEDau286xRGn2HtVpZ9AbooD3y&code=AQCACZRE3WYGMyBSII1eD-H8Sl8yDUtL6VoZ4qJPKSQ_NDBAoE_6JE7-4Ef353utpAygCZVJMUKiLNs_evC-y2oezOKRsH_njtFZW4FwPE2XoaFm14sdbtUkj1QsqivY6DSpGpsmTNCCs3twYxx-6_C-e1OWEcnd4x6SoBg59LmCUsWhocu739h_ppdLRR_wPjY
Django Version: 1.3.1
Exception Type: AuthFailed
Exception Value:    
Authentication failed: There was an error authenticating the app
Exception Location: /app/.heroku/src/social-auth/social_auth/backends/facebook.py in auth_complete, line 131Request Method: GET
Request URL:    http://[site_url]/complete/facebook/?state=DHlD9efEDau286xRGn2HtVpZ9AbooD3y&code=AQCACZRE3WYGMyBSII1eD-H8Sl8yDUtL6VoZ4qJPKSQ_NDBAoE_6JE7-4Ef353utpAygCZVJMUKiLNs_evC-y2oezOKRsH_njtFZW4FwPE2XoaFm14sdbtUkj1QsqivY6DSpGpsmTNCCs3twYxx-6_C-e1OWEcnd4x6SoBg59LmCUsWhocu739h_ppdLRR_wPjY

My requirements file is pointing to a forked version of django-social-auth so I could put some print statements around the error. The failure seems to occur after making a call to

https://graph.facebook.com/oauth/access_token?code=AQCc6tIfxJTQN64GGQsDVbT4BCK1hYGypw2oMFQjjMQf-kfJqrWtI-vGe78fJJJHTL6w5yuau90vQu8msVGDpZh30HgUYkwdXhAKJcC9MCf8h6bp1e23wxkkMzP5eaT2j7xOCorn-KgeRv-ZJA40U87GDx1_592amAlSemS4zhXaoAv7JWRHl9NzBFtJ6cuGdbg&client_secret=[app_secret]&redirect_uri=http%3A%2F%2F[site_url]%2Fcomplete%2Ffacebook%2F%3Fredirect_state%3DDHlD9efEDau286xRGn2HtVpZ9AbooD3y&client_id=[app_id]

The error I'm getting from that is

{
      "error": {
      "message": "Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request",
      "type": "OAuthException",
      "code": 100
   }
}

However if i add a slash to the end of the url I get this error:

{
   "error": {
     "message": "Error validating application. Invalid application ID.",
     "type": "OAuthException",
     "code": 101
  }
}

I assure you that app_id is correct

I know this has been a long read but does anyone have any suggestions on how to fix this?


原文:https://stackoverflow.com/questions/13884308
更新时间:2024-01-14 13:01

最满意答案

是,

如果您不希望在B之前放置A,那么前向声明是唯一的解决方案(如果您不想更改B的定义 - 请参阅Zac Howland对其他改变B的想法的回答)。 没有什么不妥。 不知何故,来自B的方法需要知道A是什么(在这种情况下,它是一个类)。 或者,编译器会通过查找定义来找出它,或者您将帮助编译器进行前向声明。


Yes,

if You don't want to place A before B, then forward declaration is the only solution in that case (if You don't want to change definition of B - see Zac Howland answer for other ideas that change B). There is nothing wrong with that. Somehow, methods from B needs to know what A is (in that case it is a class). Either, compiler will figure it out by finding A definition or You will help the compiler with forward declaration.

相关问答

更多
  • 好吧,它与C语言中的错误一样多。 考虑到问题是基于“假设”代码从C编译器的角度来看是有效的,让我详细说明,根据规范( C11 ),不允许隐式声明函数。 使用严格的一致性编译代码并且(任何符合标准的)编译器将在C中产生相同的错误。 查看实例 引用C11 ,前言/第7页, “第二版的主要变化包括:” 删除隐式函数声明 同样存在于C99 。 注意: 为什么它可能有效 在C99 ,这个代码实际上有成功编译的空间。 如果缺少函数原型,则假定函数返回一个int并接受任意数量的参数作为输入。 现在非常非标准,具有遗留支持 ...
  • 将它们放在标题中,以便所有需要它们的文件都可以访问标题并使用它的声明。 在编译时使用以下选项: $ /usr/bin/gcc -g -std=c99 -Wall -Wextra -c enum.c $ GCC 4.2.1(在MacOS X 10.7.1上)接受以下代码: enum xyz; struct qqq { enum xyz *p; }; enum xyz { abc, def, ghi, jkl }; 警告说: $ /usr/bin/gcc -g -std=c99 -Wall -Wextr ...
  • 为了让new T编译, T必须是完整的类型。 在你的情况下,当你在tile_tree::tick的定义里面说new tile_tree_apple时, tile_tree_apple是不完整的(它已经被提前声明,但是它的定义在你的文件后面)。 尝试将函数的内联定义移动到单独的源文件,或者至少将其移动到类定义之后。 就像是: class A { void f1(); void f2(); }; class B { void f3(); void f4(); }; inline v ...
  • 是, 如果您不希望在B之前放置A,那么前向声明是唯一的解决方案(如果您不想更改B的定义 - 请参阅Zac Howland对其他改变B的想法的回答)。 没有什么不妥。 不知何故,来自B的方法需要知道A是什么(在这种情况下,它是一个类)。 或者,编译器会通过查找定义来找出它,或者您将帮助编译器进行前向声明。 Yes, if You don't want to place A before B, then forward declaration is the only solution in that case ...
  • 是的,这就是(草案)标准所说的( §5.3.5.5 ); 如果被删除的对象在删除时具有不完整的类类型,并且完整的类具有非平凡的析构函数或释放函数,则行为未定义。 (一个非平凡的析构函数是你自己定义的) 要修复它,只需在header.cpp #include "Character.h" ,然后再调用delete以允许完全声明类型。 Yep, that's what the (draft) standard says (§5.3.5.5); If the object being deleted has inc ...
  • 这是有效的。 标准说: 9.7嵌套类声明 [class.nest] 如果在命名空间作用域中定义了类X ,则可以在类X声明嵌套类Y ,然后在类X (...)的定义中定义。 以下示例也是: class E { class I1; // forward declaration of nested class class I2; class I1 { }; // definition of nested class }; class E::I2 { }; 来源: C ++ 11 draft n32 ...
  • 你没有包括它就预先声明了这个类。 例如: //#include "Foo.h" // including Foo.h causes circular reference class Foo; class Bar { ... }; You predeclare the class without including it. For example: //#include "Foo.h" // including Foo.h causes circular reference class Foo; cla ...
  • 或者有没有办法做前向声明,就像在C ++中用C语言完成一样? 不,你不能在这里使用前向声明。 为什么前向声明不起作用的理由: 当您使用任何类型的前向声明时,编译器不知道它的组成也不知道其中的成员,编译器只知道该类型存在。 因此,它是编译器的不完整类型 。 对于不完整的类型,一个人不能创建它的对象或做任何需要编译器知道类型的布局的事情,或者更多的事情,它只是一个类型。 由于指向所有对象的指针只需要相同的内存分配,因此只需将类型作为指针进行复制即可使用前向声明。 但是,这里编译器需要知道Titem类型的布局和大 ...
  • 你有一个循环引用,所以你需要分离Bh尝试像这样: BH: #ifndef B_H_ #define B_H_ // don't include A.h here! class A; class B { private: A& a; public: B(A& a) : a(a) {} void foo(); }; #endif /*B_H_*/ B.cpp: #include "B.h" #include "A.h" void B::foo() ...
  • 您没有完整声明就使用Robot 。 将onEvent实现移动到cpp文件中并在其中包含robot.h头文件,或者只在robot.h中userreceiver.h 。 我推荐前者。 You are using Robot without having a full declaration. Either move the onEvent implementation into a cpp file and include the robot.h header there, or just #include t ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)