asp.net - Google API Calendar v3 Token Authentication only once -


i have searched days, can't answer, create post.

i developed web app, user can create event in google calendar. working. but, can't figure, why app asks user credential once.

for example:

  1. user john access .aspx page redirected google authorized page because it's first time john access page.
  2. after authorized, john can create event in google calendar.

it works until step. problem occurred when john logout google account.

  1. if dave accesses page computer, he's not redirected google authorized page , directly creates event in john's calendar.

can me, why problem occurred?

this code:

protected sub new_authentication()     dim datafolder string = server.mappath("app_data/calendarservice.api.auth.store")     dim scopes ilist(of string) = new list(of string)()     dim userid string = "googleid_co"      scopes.add(calendarservice.scope.calendar)     dim myclientsecret new clientsecrets() { _       .clientid = myclientid, _       .clientsecret = clientsecret _     }      dim flow googleauthorizationcodeflow      flow = new googleauthorizationcodeflow(new googleauthorizationcodeflow.initializer() { _       .datastore = new filedatastore(datafolder), _       .clientsecrets = myclientsecret, _       .scopes = scopes _     })      dim uri string = request.url.tostring()      dim code = request("code")     if code isnot nothing         dim token = flow.exchangecodefortokenasync(userid, code, uri.substring(0, uri.indexof("?")), cancellationtoken.none).result          ' extract right state.         dim oauthstate = authwebutility.extracredirectfromstate(flow.datastore, userid, request("state")).result         response.redirect(oauthstate)     else         dim result = new authorizationcodewebapp(flow, uri, uri).authorizeasync(userid, cancellationtoken.none).result         if result.redirecturi isnot nothing             ' redirect user authorization server.             response.redirect(result.redirecturi)         else             ' data store contains user credential, user has been authenticated.             mycalendarservice = new calendarservice(new baseclientservice.initializer() { _               .applicationname = "my calendar", _               .httpclientinitializer = result.credential _             })              createcalendar()           end if     end if  end sub 

this createcalendar sub

protected sub createcalendar()    dim newevent new [event]() { _        .summary = "google i/o 2015", _        .location = "800 howard st., san francisco, ca 94103", _        .description = "a chance hear more google's developer products.", _        .start = new eventdatetime() { _            .datetime = datetime.parse("2015-07-13t09:00:00-07:00"), _            .timezone = "america/los_angeles" _        }, _        .[end] = new eventdatetime() { _            .datetime = datetime.parse("2015-07-14t17:00:00-07:00"), _            .timezone = "america/los_angeles" _        }, _        .recurrence = new [string]() {"rrule:freq=daily;count=2"}, _        .attendees = new eventattendee() {new eventattendee() { _            .email = "lpage@example.com" _        }, new eventattendee() { _            .email = "sbrin@example.com" _        }}, _        .reminders = new [event].remindersdata() { _            .usedefault = false, _            .[overrides] = new eventreminder() {new eventreminder() { _                .method = "email", _                .minutes = 24 * 60 _            }, new eventreminder() { _                .method = "sms", _                .minutes = 10 _            }} _        } _    }      dim calendarid [string] = "primary"     dim request eventsresource.insertrequest = mycalendarservice.events.insert(newevent, calendarid)     dim createdevent [event] = request.execute() end sub 

i resolved problem. found name of token same that's why problem occurred. so, replace code:

dim datafolder string = server.mappath("app_data/calendarservice.api.auth.store") dim scopes ilist(of string) = new list(of string)() dim userid string = "googleid_co" 

into

dim datafolder string = server.mappath("app_data/calendarservice.api.auth.store") dim scopes ilist(of string) = new list(of string)() dim userid string = "googleid_co" & {unique identifier such userid,username,etc} 

Comments