Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

access_token to external login by provider #161

Merged
merged 7 commits into from

4 participants

@rafaelsachetto

support to get access token of external login, new external method access_token added

@rafaelsachetto

Sorry about the commit trash, I forgot the other clients and after cleaning a space code, I tried the amend but it was not a good idea.

@NoamB NoamB merged commit daaeefc into NoamB:master
@NoamB
Owner

Thanks.

@przemad

I think, this is wrong, very wrong. You add access_token to class methods but access_token sholud be only for user instance! When you login on firefox to your aplication and show access_token, and next you go to your site on another browser (not logged in) you can see your token.
Another thing is, that if you are logged in, and next you restart your application your access_token will be nil.
What is your opinion on this?

Any idea how to get the access token of the instance? I noticed this error as well but decided to rush in putting the token in a session once logged in (the project was timely and no longer active)

This is my solution przemad@8c9c5a8
I try to prepare pull request in this weekend to fix this. There is no test for this yet :/

@willywg
Collaborator

This method currently dont work fine... This get a OAuth2::AccessToken object .... don't the access_token value... You can fix that change @provider.access_token.token

cc: @rafaelsachetto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
6 lib/sorcery/controller/submodules/external.rb
@@ -51,6 +51,12 @@ def login_from(provider)
user
end
end
+
+ # get provider access account
+ def access_token(provider)
+ @provider = Config.send(provider)
+ @provider.access_token
+ end
# this method automatically creates a new user from the data in the external user hash.
# The mappings from user hash fields to user db fields are set at controller config.
View
3  lib/sorcery/controller/submodules/external/providers/facebook.rb
@@ -36,7 +36,8 @@ class << self
:scope,
:user_info_mapping,
:display
-
+ attr_reader :access_token
+
include Protocols::Oauth2
def init
View
1  lib/sorcery/controller/submodules/external/providers/github.rb
@@ -36,6 +36,7 @@ class << self
:site,
:user_info_path,
:user_info_mapping
+ attr_reader :access_token
include Protocols::Oauth2
View
1  lib/sorcery/controller/submodules/external/providers/google.rb
@@ -37,6 +37,7 @@ class << self
:user_info_url,
:scope,
:user_info_mapping
+ attr_reader :access_token
include Protocols::Oauth2
View
1  lib/sorcery/controller/submodules/external/providers/liveid.rb
@@ -37,6 +37,7 @@ class << self
:user_info_url,
:scope,
:user_info_mapping
+ attr_reader :access_token
include Protocols::Oauth2
View
3  lib/sorcery/controller/submodules/external/providers/twitter.rb
@@ -37,7 +37,8 @@ class << self
:site,
:user_info_path,
:user_info_mapping
-
+ attr_reader :access_token
+
include Protocols::Oauth1
# Override included get_consumer method to provide authorize_path
Something went wrong with that request. Please try again.