Custom Oauth Login

I do a custom Oauth Login. I meet a problem:
When do account binding:
Login via third party’s account/password and back to edx . The “logged in” status of the edx would become “not logged in”. Could someone give advice?
( In “Ironwood” , the function still works. After version : “Juniper”, the function is not working. )

(Select binding account : )

def signin_nid(request):
xclient_id = Xschools.objects.get(xschool_id=‘FCU’).xschool_client
xclient_url = Xschools.objects.get(xschool_id=‘FCU’).return_uri
return redirect(
‘https://[ third party oauth url ]?client_id=’ + xclient_id + ‘&client_url=’ + xclient_url)

( Login via third party’s account/password and then back to ‘return_nid’ )

def return_nid(request):
if request.method == ‘POST’:
if int(request.POST[‘status’]) == 200:
…( Do binding )