code = deviceInfo['device_code']
myAPI.updatePrivileges(code)

# As a reference the provided access-token can be obtained from the BaseSpaceApi object
print "\nMy Access-token:"
print myAPI.getAccessToken()

# Let's try and grab all available genomes with our new api!
allGenomes = myAPI.getAvailableGenomes()
print "\nGenomes \n" + str(allGenomes)

# If at a later stage we wish to initialize a BaseSpaceAPI object when we already have
# an access-token from a previous sessions, this may simply be done by initializing the BaseSpaceAPI
# object using the key-word AccessToken.
myToken = myAPI.getAccessToken()
myAPI.setAccessToken(myToken)
print "\nA BaseSpaceAPI instance was updated with an access-token: "
print myAPI

#################### Web-based verification #################################
# The scenario where the authentication is done through a web-browser

if clientKey:
    BSapiWeb = BaseSpaceAPI(clientKey, clientSecret, apiServer, apiVersion,
                            appSessionId)
else:
    BSapiWeb = BaseSpaceAPI(profile='DEFAULT')
userUrl = BSapiWeb.getWebVerificationCode('browse global',
                                          'http://localhost',
                                          state='myState')
# As a reference the provided access-token can be obtained from the BaseSpaceApi object
print "\nMy Access-token:"
print myAPI.getAccessToken()


# Let's try and grab all available genomes with our new api! 
allGenomes  = myAPI.getAvailableGenomes()
print "\nGenomes \n" + str(allGenomes)


# If at a later stage we wish to initialize a BaseSpaceAPI object when we already have
# an access-token from a previous sessions, this may simply be done by initializing the BaseSpaceAPI
# object using the key-word AccessToken.
myToken = myAPI.getAccessToken()
myAPI.setAccessToken(myToken)
print "\nA BaseSpaceAPI instance was updated with an access-token: "
print myAPI 

#################### Web-based verification #################################
# The scenario where the authentication is done through a web-browser

if clientKey:
    BSapiWeb = BaseSpaceAPI(clientKey, clientSecret, apiServer, apiVersion, appSessionId)
else:
    BSapiWeb = BaseSpaceAPI(profile='DEFAULT')
userUrl= BSapiWeb.getWebVerificationCode('browse global','http://localhost',state='myState')

print "\nHave the user visit:"
print userUrl