• CosminC
  • NEWBIE
  • 25 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
Hello,

I have setup an Authentication Provider and Named Credential to authenticate to Google (specifically Google Calendar), this has worked fine in Sandbox for the past 2 weeks (and is still authenticated as I write this, using a free Gmail account). The problem came when I needed to replicate this in production, where I'm using the same settings though adjusted with the production domain url for the callback. Now the Named Credential fails to authenticate. The error I get is Remote_Error: invalid_request

If I edit the Sandbox Named Credential which is currently authenticated and click save to start the auth flow again, then I get the same error in the Sandbox environment, however that one stays authenticated even after that (same if I use the Test-Only Initialization URL inside Auth.Provider)

I have also tried using a different Gmail account with a new project in the google console, different client secret and id, but I got the same error.

My authentication provider is using Open ID Connect as Provider Type. I have also tried using Google as provider type however I get a different error: Id_Token_Error: Missing id_token

User-added image
User-added image
User-added image
User-added image

Any help would be kindly appreciated.
Thanks,
Cosmin
  • September 27, 2018
  • Like
  • 0
Hello,

I have an After Insert trigger on Event which uses data from the related EventRelation objects to get the list of invitees and further create an event in Google Calendar.

I am trying to write a test class for this, inserting an event with invitees, however if I first insert the Event and then I insert EventRelation records to create the invitees, my trigger already fires on the Event insertion which will have no invitees at that point. Is there a way to insert the Event directly with invitees? (I can't seem to find a List of WhoId records on the Event object that would be available through Apex on Event insertion).
 
// setup test data
        Account a = new Account();
        a.Name = 'Test account';
        insert a;
        
        List<Contact> contacts = new List<Contact> {new Contact(LastName = 'Test Con1', Email = 'test@test.ro'), new Contact(LastName = 'Test con2', Email = 'test@test.com')};
        insert contacts;
        
	Event e = new Event();
        e.Description = 'Test event description';
        e.Subject = 'Test event subject';
        e.IsAllDayEvent = false;
        e.IsRecurrence = false;
        e.StartDateTime = DateTime.now();
        e.EndDateTime = DateTime.now().addHours(1);
        insert e;
        
// trigger will already fire here, before EventRelation records are inserted.

        EventRelation er1 = new EventRelation();
        er1.EventId = e.Id;
        er1.IsInvitee = true;
        er1.IsWhat = false;
        er1.RelationId = contacts.get(0).Id;
        EventRelation er2 = new EventRelation();
        er2.EventId = e.Id;
        er2.IsInvitee = true;
        er2.IsWhat = false;
        er2.RelationId = contacts.get(1).Id;
        List<EventRelation> ers = new List<EventRelation>{er1, er2};
        insert ers;

Thanks in advance
  • September 25, 2018
  • Like
  • 0
Hello,

I have setup an Authentication Provider and Named Credential to authenticate to Google (specifically Google Calendar), this has worked fine in Sandbox for the past 2 weeks (and is still authenticated as I write this, using a free Gmail account). The problem came when I needed to replicate this in production, where I'm using the same settings though adjusted with the production domain url for the callback. Now the Named Credential fails to authenticate. The error I get is Remote_Error: invalid_request

If I edit the Sandbox Named Credential which is currently authenticated and click save to start the auth flow again, then I get the same error in the Sandbox environment, however that one stays authenticated even after that (same if I use the Test-Only Initialization URL inside Auth.Provider)

I have also tried using a different Gmail account with a new project in the google console, different client secret and id, but I got the same error.

My authentication provider is using Open ID Connect as Provider Type. I have also tried using Google as provider type however I get a different error: Id_Token_Error: Missing id_token

User-added image
User-added image
User-added image
User-added image

Any help would be kindly appreciated.
Thanks,
Cosmin
  • September 27, 2018
  • Like
  • 0
Hello,

I have an After Insert trigger on Event which uses data from the related EventRelation objects to get the list of invitees and further create an event in Google Calendar.

I am trying to write a test class for this, inserting an event with invitees, however if I first insert the Event and then I insert EventRelation records to create the invitees, my trigger already fires on the Event insertion which will have no invitees at that point. Is there a way to insert the Event directly with invitees? (I can't seem to find a List of WhoId records on the Event object that would be available through Apex on Event insertion).
 
// setup test data
        Account a = new Account();
        a.Name = 'Test account';
        insert a;
        
        List<Contact> contacts = new List<Contact> {new Contact(LastName = 'Test Con1', Email = 'test@test.ro'), new Contact(LastName = 'Test con2', Email = 'test@test.com')};
        insert contacts;
        
	Event e = new Event();
        e.Description = 'Test event description';
        e.Subject = 'Test event subject';
        e.IsAllDayEvent = false;
        e.IsRecurrence = false;
        e.StartDateTime = DateTime.now();
        e.EndDateTime = DateTime.now().addHours(1);
        insert e;
        
// trigger will already fire here, before EventRelation records are inserted.

        EventRelation er1 = new EventRelation();
        er1.EventId = e.Id;
        er1.IsInvitee = true;
        er1.IsWhat = false;
        er1.RelationId = contacts.get(0).Id;
        EventRelation er2 = new EventRelation();
        er2.EventId = e.Id;
        er2.IsInvitee = true;
        er2.IsWhat = false;
        er2.RelationId = contacts.get(1).Id;
        List<EventRelation> ers = new List<EventRelation>{er1, er2};
        insert ers;

Thanks in advance
  • September 25, 2018
  • Like
  • 0