django rest auth - FacebookLogin view, missing 1 required positional argument 'request' - django-allauth

I'm following the django-rest-auth Social Authentication installation guide for Facebook, and have implemented the FacebookLogin class as a subclass of SocialLoginView, with adapter_class set to the FacebookOAuth2Adapter adapter, as per the install guide.
When I then post a request to /rest-auth/facebook I get the following error message "TypeError: init() missing 1 required positional argument: 'request' " from registration_serializers.py, line 63 (adapter = adapter_class() )
Am I missing a setting? Perhaps an allauth social setting somewhere? Thanks

This is a bug with django-rest-auth and django-allauth > 0.25.
Workaround is to pass an init into the adapter, I've verified this works with my project.
class FacebookOAuth2AdapterCustom(FacebookOAuth2Adapter):
def __init__(self):
pass
class FacebookLogin(SocialLoginView):
adapter_class = FacebookOAuth2AdapterCustom
An issue with django-rest-auth has been submitted: https://github.com/Tivix/django-rest-auth/issues/197

Related

Unable to issue identity in Hyperledger Composer

I am trying to issue an identity to a participant that already exists in the network.
return this.bizNetworkConnection.connect(this.cardname)
.then((result) => {
let email = 'user#gmail.com',
username = email.split('#')[0];
this.businessNetworkDefinition = result;
return this.bizNetworkConnection.issueIdentity('org.test.Person#user#gmail.com', username);
})
.then((result) => {
console.log(`userID = ${result.userID}`);
console.log(`userSecret = ${result.userSecret}`);
})
I expect that I will see the userID and the userSecret logged on the console but I am getting errors as described below.
Following the developer tutorial on their documents:
If I use the card name for PeerAdmin#hlfv1 on the connect function above, I get the error. "Error trying to ping. Error: Error trying to query business network. Error: Missing \"chaincodeId\" parameter in the proposal request"
If I use the card name for admin#tutorial-network on the connect function above, I get the error "fabric-ca request register failed with errors [[{\"code\":400,\"message\":\"Authorization failure\"}]]"
For option 1, I know the network name is missing in the given card, whie option 2 means that the admin has no rights to issue an identity. However, I cannot seem to find any documentation directing me on how to use either to achieve my objective. Any help is highly welcome.
While I have listed the javascript code I am using to achieve the same, I would not mind if anyone can explain what I am missing using the composer cli.
see https://hyperledger.github.io/composer/latest/managing/identity-issue.html
you would definitely use the admin#tutorial-network card, as PeerAdmin does not have authority to issue identities (admin does).
Did you already do: 1) a composer card import -f networkadmin.card (per the tutorial) ? 2) a composer network ping -c admin#tutorial-network to use the card (now in the card store) and thereby populate the admin's credentials (certificate/private key).
Only at that point would admin be recognised as the identity to issue further identities. Is it possible you spun up a new dockerized CA server at some stage since you did the import etc ?
What happens if you issue a test identity through the command line (using admin#tutorial-network? Does it fail)

How to get authentication from user in linkedin?

I am new in creating a application in linkedin. Can some one help in getting the authorization??
I tried this code:
https://www.linkedin.com/uas/oauth2/authorization?response_type=code
&client_id=78lv1rv8ryh1hf
&scope=scope=r_fullprofile%20r_emailaddress%20r_network
&state=DCEEFWF45453sdffef424
&redirect_uri=http://www.mycoolsite.com
I am getting error saying that ...
error=unsupported_response_type&error_description=We+only+support+a+response_type+of+"code"%2C+but+you+passed+code+
There are a few things that can be improved:
you have not URL-encoded the redirect_uri parameter value
you're passing scope= in the scope value, which seems to be a typo/duplicate
you may have inserted a space/line-break in your URL since the following works for me:
https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=78lv1rv8ryh1hf&scope=r_fullprofile%20r_emailaddress%20r_network&state=DCEEFWF45453sdffef424&redirect_uri=http%3A%2F%2Fwww.mycoolsite.com

I can't seem to get the first Twitter4J code example (Simple post on Twitter) to work. UpdateStatus(string) is undefined

So this is my problem right now:
I went to http://twitter4j.org/en/code-examples.html as I just started to use twitter4j (version 4.0.2 as far as I can remember) and I wanted to try to code examples to get a basic understanding of T4J.
However, it seems like I can't even get the first example to work. This is my code right now:
import twitter4j.Status;
import twitter4j.TwitterFactory;
public class Twitter {
public static void main(String[] args) {
String latestStatus="Test";
Twitter twitter = (Twitter) TwitterFactory.getSingleton();
Status status = twitter.updateStatus(latestStatus);
System.out.println("Successfully updated the status to [" + status.getText() + "].");
}
}
This is exactly to code I found on code examples (Plus the string which should end up being the status). However, I always get an error at Status status=twitter.updateStatus(latestStatus), which is basically this:
The method updateStatus(String) is undefined for the type Twitter
I have literally no idea what could be wrong here. I mean in the end it's the official code example. Even the official doc is using strings as parameter for that method.
Can anyone give me a helping hand?
Thanks in advance.
You need couple of things to make this code work -
First you need to register your app with Twitter and generate OAuth Authentication. You will get following - consumerkey, consumersecret, accesstoken and accesstokensecret.
Using the keys and secret you would create a Twitter instance, which you can use to access your Twitter User ID.
Second you need to authorize your app to be able to write updates default permission is Read Only.
You can register and manage your app at https://apps.twitter.com/
Also about the twitter$j library version, please use a latest one.
Here is a code snippet to use the authentication keys and update the status -
import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder;
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true)
.setOAuthConsumerKey("consumerKey")
.setOAuthConsumerSecret("consumerSecret")
.setOAuthAccessToken("accessToken")
.setOAuthAccessTokenSecret("accessTokenSecret");
Twitter twitter = new TwitterFactory(cb.build()).getInstance();
Status status = twitter.updateStatus("test");
Hope this is helpful.
This is happening because your class is called Twitter, so
Twitter twitter = new TwitterFactory(cb.build()).getInstance();
will be interpreted as you trying to create an instance of your class Twitter, rather than an instance of twitter4j.Twitter. You could change the name of your class to something else, or change the library Twitter instances to twitter4j.Twitter instances to specify the difference.

xmpp4r and Iq.new_register for in-band registration

I've been having trouble using xmpp4r to do in-band registration following the SO thread here:
XMPP transport to another protocol
The problem comes down to that I get a NoMethodError Exception error for new_register when I run the following code:
require "xmpp4r"
require "xmpp4r/client"
require "xmpp4r/iq"
def in_band_reg
chat_name = 'testChatName'
password = 'pword'
reg = Jabber::Iq.new_register(chat_name, password)
end
NoMethodError Exception: undefined method `new_register' for Jabber::Iq:Class
In the xmpp4r gem in the file iq.rb I can see the new_register method defined as:
def Iq.new_register(username=nil, password=nil)
...
end
but when I examine the class's methods I'm not able to see the new_register method. I.E.
Jabber::Iq.singleton_methods(false)
["new_authset", "new_rosterget", "new_vcard", "new_rosterset", "import", "new_authset_digest", "new_query", "add_elementclass", "new_browseget"]
Jabber::Iq.public_instance_methods(false)
["query=", "queryns", "set_type", "type", "typed_add", "type=", "query", "vcard"]
Jabber::Iq.respond_to?("new_register")
false
Any idea why I can't access the new_register method in 'xmpp4r/iq' ?
I got this working by just coding it up myself. First connect a client that can in-band register new users:
jid = JID::new('admin#ejabberd.server.com/res')
client = Client::new(jid, false)
client.connect
client.auth("admin_password")
then have that client register a new user by sending an in-band message
iqr = Iq.new(:set)
qr = IqQuery.new
qr.add_namespace('jabber:iq:register')
username = 'new_user'
password = 'new_user_password'
qr.add(REXML::Element.new('username').add_text(username))
qr.add(REXML::Element.new('password').add_text(password))
iqr.add(qr)
client.send iqr
What version of xmpp4r are you using? Have you tried the GitHub version?
gem sources -a http://gems.github.com (you only need to do this once!)
gem install ln-xmpp4r

Trouble with authlogic_rpx

I'm trying to run http://github.com/tardate/rails-authlogic-rpx-sample (only rails version was changed) but get error message http://gist.github.com/385696, when RPX returns information after successful authentication via Google Account. What is wrong here? And how I can fix it?
The code was successfully tested with rails 2.3.3 by its author: http://rails-authlogic-rpx-sample.heroku.com/
I run on Windows with cygwin and rails (2.3.5), rpx_now (0.6.20), authlogic_rpx (1.1.1).
Update
In several hours RPX rejected my app http://img96.imageshack.us/img96/2508/14128362.png
Update2
The same error message ( http://gist.github.com/386124) appears with http://github.com/grosser/rpx_now_example , but in this case RPX allows me to sign in (so far).
Solved
See below
Got error: Invalid parameter: apiKey (code: 1), HTTP status: 200
You have to first register your RPX app at http://www.RPXnow.com and set its name. You'll be assigned an API key which you should set in the config/environment.rb file:
RPX_API_KEY = ENV["RPX_API_KEY"]
RPX_APP_NAME = "your_app_name_here!"
Or: Read slide 35: http://www.slideshare.net/tardate/srbauthlogicrpx
You shouldn't have any constraints enforced at the database level.
The reason was trailing \r character in my API key. Apparently, non of the steps did key trimming and the exception was not processed in a good way.

Resources