This is what I've added on db.py. Hope this helps.

==============

from instagram.client import InstagramAPI
access_token = access_token
client_secret= client_secret
client_id = client_id
redirect_uri = redirect_uri

auth = Auth(db)

auth_table = db.define_table(
    auth.settings.table_user_name,
    Field('fullname', 'string', default=""),
    Field('first_name', length=128,default=''),
Field('last_name', length=128,default=''),
Field('email', length=128,default=''),
    Field('username', 'string', unique=True),
    Field('user_bio', 'text', default=""),
    Field('website', 'string', default=""),
    Field('profile_picture', 'string', default=""),
    Field('instagram_id', 'string', unique=True),
    Field('password', 'password', length=256, readable=False, 
label='Password'),
    Field('access_token','string'),
    Field('registration_id', length=128, default= "", writable=False, 
readable=False))

auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username)
auth.define_tables()

class InstagramOauth():
def login_url(self, next="/"):
from instagram import client
instagram_client = client.InstagramAPI(client_id= client_id, 
client_secret=client_secret, redirect_uri=redirect_uri)
return instagram_client.get_authorize_url(scope=["likes","comments"])
 def get_user(self):
from instagram import client
instagram_client = client.InstagramAPI(client_id= client_id, 
client_secret=client_secret, redirect_uri=redirect_uri)
if request.vars.code:
code = request.vars.code
access_token, instagram_user = 
instagram_client.exchange_code_for_access_token(code)
return dict(username = instagram_user['username'],instagram_id = 
instagram_user['id'],user_bio=instagram_user['bio'],website = 
instagram_user['website'],profile_picture = 
instagram_user['profile_picture'],full_name=instagram_user['full_name'],registration_id
 
= instagram_user['id'],access_token=access_token)

auth.settings.login_form = InstagramOauth()

On Sunday, April 19, 2015 at 6:44:40 PM UTC-4, www.diazluis.com wrote:
>
> greetings,
> one could publish the adapted code
> to login on instagram?
>
> try to, but I overcame :(
>
>
> I do not have the ability to adapt
> oauth20_account.py to work with it:
>
> from instagram.client import InstagramAPI
> instagram_api = InstagramAPI(client_id=CLIENT_ID, 
> client_secret=CLIENT_SECRET, redirect_uri=REDIRECT_URI)
> auth.settings.login_url = instagram_api.get_authorize_login_url(scope = 
> 'basic')
>
> instagram_code = request.vars.code or None
>
> if instagram_code:
>     instagram_token, user_info = 
> instagram_api.exchange_code_for_access_token(code)
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to