Trouble getting code parameter on facebook oauth callback - python

I'm writing a Django app requesting permission to post on facebook.
I can access authorization and callback, but I can't get the parameter 'code' that facebook needs to continue with oauth.
def connect_fb(request):
return redirect("https://graph.facebook.com/oauth/authorize?"
+"client_id=MY_ID&"
+"redirect_uri=MY_URL"
+"&type=user_agent&display=popup&scope=publish_stream")
def callback_facebook(request):
code=request.REQUEST.get("code")
What's the right way to get 'code' so I can continue the oauth process?
I tried several things but I keep getting None instead of a code.
Thanks

I've used django-facebook-oauth in the past, but if you really want to roll your own solution then I'd suggest just looking through their source.
From just glancing through it, the only thing I can see you doing differently is the
&type=user_agent&display=popup
in the URL. The app I linked you to doesn't appear to do that as far as I can tell.

The problem comes from type=user_agent that is used in javascript authentication, and not here.
Removing it allows to get code as above.

Related

Updating clientStates in cloudidentity api failing

Following the guide in Google's documentation I am attempting to update fields for a device. This returns Permission denied. Did you provide the correct client id? which I have verified is absolutely the correct id.
If I log the error.msg I get HTTP Error 400: Bad Request, and looking at the contents I see that
<p>The requested URL <code>/v1/devices/abc123/deviceUsers/abc-123-ddd/clientState/companyid-string?updateMask=healthScore</code> was not found on this server. <ins>That\xe2\x80\x99s all we know.
I took the resource name from using the list method, as suggested by the docs, so I am fairly certain this is the correct name. I don't believe its a scope permission error as the scope listed works to list/get devices.
I have tried updating different fields, different devices, and switching it up as much as I could think to do and still run into a 400. If anyone has updated any of the clientState fields and can provide guidance I would greatly appreciate it.

Error 16112 - How to connect to Ebay without interactivity?

So, I'm trying to use the ebaysdk-python module, to connect to ebay and get a list of orders. After struggle a little bit with the connection, I've finally have found the ebay.yaml syntax. I have then configured the user and password, but I'm receiving this Error 16112.
So, this is my question: is there a way to connect to ebay without interactivity? I mean, without the need to give the permission to get the token and such (oauth)?
I've finally found the way to do this: I have created a user token using the method auth'n'auth. This user token have almost a year of validity, so it can be used for my purpose. Now, there is another question around that.

Weibo API auth error

I started to write a project for Sina Weibo and got a problem from the start.
When I make a get request to API:
http://api.t.sina.com.cn/statuses/public_timeline.json?source=App_key&count=5
I get an error of authentication such as:
{"request":"/statuses/public_timeline.json","error_code":"403","error":"40070:Insufficient app permissions!"}
or another request and answer:
https://api.weibo.com/2/statuses/user_timeline.json?source=Appkey&trim_user=1&count=100&screen_name=michael
{"error":"applications over the unaudited use restrictions!","error_code":21321,"request":"/2/statuses/user_timeline.json"}
Can someone help me to make this request work?
I just don't het If I need to send token somehow or secret-key.. I am new at development and would be glad if someone answers.
Probably to late, but for future uses. Weibo requires all request to be OAuth2 authenticated. So before using that you need to give permissions and generate access tokens. It's common practice. Services like twitter provide smaller limits also for unauthenticated users, to ease developer live, however that's not the case with weibo :(
If you are working with weibo I highly recommend this article ->
https://www.cs.cmu.edu/~lingwang/weiboguide/

Posting to Facebook wall in python

I have some strange issue, which maybe doesn't relate to coding at all (in which case I apologize).
I'm trying to post on my facebook wall using python, and I use facepy library. Code looks like something like this:
graph = GraphAPI(access_token)
graph.post(
path='me/feed',
message = message)
It posts a message on my wall, but this message is only visible for me. None of my friends can see this. I don't why is this, my app has public activity privacy and manually I can post messages that every one sees.
What can cause this behavior?
Have you tried setting the privacy settings?
Refer to the Facebook API on Privacy here: https://developers.facebook.com/docs/reference/api/privacy-parameter/
Specifically, you will want to use privacy={'value':'EVERYONE'} before posting.
you should include the whole JSON string
"privacy" = '{"value":"EVERYONE|SELF|...etc"}'

Setting up a Python ViewServer for CouchDB

I am trying to get up to speed with CouchDB. As a relatively new user on Python, I am trying to set up a view-server so that I can pass on python functions to couchdb.design.ViewDefinitions function. As I understand, ViewDefinitions take javascript code to execute map/reduce function.
Here is what I struggle to understand - I am well aware that this might be a basic question. According to wiki (http://wiki.apache.org/couchdb/View_server):
To register query servers with CouchDB, add a line for each server to local.ini. The basic syntax is:
'[query_servers] python=/usr/bin/couchpy'
How do I access local.ini file? I am an 10.6.8 Mac user. Thanks!
Update: Thank you Kxepal. It seems I was able to create the design/view on Futon in Python. Alternatively, I figured that python viewserver can be created as follows:
curl -X PUT http://[localhost]/_config/query_servers/python '"/path/to/couchpy"'
However, I still cannot execute the python script. Running the view on Couch results in following:
'Error: An error occurred accessing the view no response'
I would appreciate if somebody can point in the right direction. Thanks!
I encountered the same "Error: An error occurred accessing the view no response" problem, and it turned out to be a bug in my python code. Specifically, in the javascript implementation I had something like:
function (doc) {
emit(doc.somefield, doc);
}
I had converted this to:
def map(doc):
yield doc.somefield, doc
However, this gave me the "no response" error you describe.
Changing it to the following fixed the problem.
def map(doc):
yield doc['somefield'], doc
I don't know there OSX keeps CouchDB config files, but you always may setup Python query server through Futon. On sidebar click Configuration, than "Add section" at the bottom of the page and fill the fields with same data as you planned to write into local.ini. As bonus, you don't need restart CouchDB - configuration changes through HTTP API are applied instantly, but be sure that you'd specified correct values.

Categories